Jump to content
skaterdav85

SQL Exception

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...