Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling function in database from servlet

 
Michele Smith
Ranch Hand
Posts: 421
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am having multiple problems with my stored procedure func_ConvertDecimalHours. Could anyone have a look and tell me what I am doing wrong?

 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Couple of things. Tell us more about what's happening when you run this code and what you expect. Give us the stack trace if you have one. But even without that I see a couple of issues. First, for a stored procedure you want to use a CallableStatement, not a PreparedStatement. And I don't see where you are executing the statement. Is this an update or are you expecting a ResultSet to be returned? It's hard to tell from the function name. I would expect your code to look something like this:

This is just a rough guess. I have no idea what kind of result your stored procedure is returning, but this should help you to the next step.

And please avoid using variables with one character. It's not worth the effort of deciphering the code especially several months from now.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!