Jump to content

SQL Exception


skaterdav85
 Share

Recommended Posts

I'm having trouble calling a stored procedure in java. This is my error:SQL Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'CALL'.However, when I do the exact same query by hardcoding the statement, it works.This one doesnt work

String sql = "CALL addDocument(?,?);";CallableStatement stmt = this.conn.prepareCall(sql);stmt.setString(1, this.documentNumber);stmt.setString(2, this.documentTitle);

This one works

String sql = "INSERT INTO document (documentNumber, documentTitle) VALUES (?,?);";PreparedStatement stmt = this.conn.prepareStatement(sql);stmt.setString(1, this.documentNumber);stmt.setString(2, this.documentTitle);stmt.executeUpdate();

Anyone have an idea of why this might not work? I know my SP works fine because i tested it in sql server management studio.FIXED. Apparently you cant use a semi colon in the call statement.

Edited by big dave
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...