This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Stored procedure in JSP

 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I've just started looking at Stored Procedures in MS-SQL but am having trouble finding out how to call one in my JSPs.
I was wondering if anyone would have an example or tips on doing this.
Thanx
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a number of ways you can call a stored procedure from a JSP, I suggest you look at java.sql package:
Statement, PreparedStatement and CallableStatment interfaces to see what best fits your needs.
HTH
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64631
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling any Java from a JSP scriptlet is no different than calling it from anyplace else. Since this is much more aout JDBC than JSP, I'm moving it along to the JDBC forum.
bear
 
Bob Backlund
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still trying to call the stored procedure, got this bit of code:
try
{
CallableStatement sp = conn1.prepareCall("{ CALL spdefaultcosting(?,?)}");
sp.setString(1, strJobNumber);
sp.setString(2, strCodeID);
sp.execute();
}
catch (SQLException SQLex)
{
System.out.println("Error: " + SQLex);
}
But keep getting the following error:
Error: java.sql.SQLException: Could not find stored procedure 'CALL'.
(Starting to get a little frustrating now).
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove CALL and try it. I believe a CallableStatement takes care of this for you.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a thought - try changing CALL to call (all lowercase)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic