Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with a stored procedure (SQL Server)

 
Alejandro Barrero
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stored procedure is:

My Java code is:

I am getting the exception "com.microsoft.sqlserver.jdbc.SQLServerException: The formal parameter "@id" was not declared as an OUTPUT parameter, but the actual parameter passed in requested output."

Your help would be greatly appreciated,

Alejandro Barrero
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Not sure why you are getting this error but just another thought,
Why you cannot use a PreparedStatement with a simple SQL instead of putting this SQL in the Stored proc. ?

Regards,
Amit
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I may be mistaken, but the code looks so simple that this seems like a driver bug. Are you using a correct version of your JDBC driver (that is, version recommended with the SQL Server you're using)? Can you test this code with jTDS driver instead of Microsoft's one?
 
Alejandro Barrero
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your help. The project requires that I use stored procedures for such simple things. I am using sqljdbc4.jar. Interstingly, if I run the sql statement with a Statement it works fine. The database people here would have to take care of it.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the Statement, unlike CallableStatement, doesn't use parameters at all. This is probably the reason why the error doesn't appear with Statement.

Just out of curiosity, what happens if you use CallableStatement but don't register the second parameter as output, but as input one? And can you try the jTDS driver?
 
Alejandro Barrero
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that since the second parameter @int1 is used to return Delay_Minutes it is OUTPUT in the stored procedure and has to be registered as output.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic