| Author |
SQL Stored procedure in JSP
|
Bob Backlund
Ranch Hand
Joined: Jun 05, 2003
Posts: 51
|
|
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
|
Cheers!
|
 |
Faisal Khan
Ranch Hand
Joined: Jun 29, 2003
Posts: 285
|
|
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
|
The secret to creativity is knowing how to hide your sources.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56229
|
|
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
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bob Backlund
Ranch Hand
Joined: Jun 05, 2003
Posts: 51
|
|
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
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
Remove CALL and try it. I believe a CallableStatement takes care of this for you.
|
 |
Sonny Gill
Ranch Hand
Joined: Feb 02, 2002
Posts: 1211
|
|
|
Just a thought - try changing CALL to call (all lowercase)
|
The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
|
 |
 |
|
|
subject: SQL Stored procedure in JSP
|
|
|