• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with a stored procedure (SQL Server)

 
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Vashko
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 502
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic