This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem using Callable Statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem using Callable Statement" Watch "Problem using Callable Statement" New topic
Author

Problem using Callable Statement

Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
Hi Pals,I have this scenario;
If a stored procedure has being created for me on Oracle database and i need
to execute the stored procedure via my JSP ,where i capture some parameters in
my JSP,send this parameters to the Stored Procedure . Then the Stored procedure decides if its an Update or Insert depending on the PL/SQL(Stored Procedure) code on database.
How do i go about this using The CallableStatement java API and obviously JDBC.
All suggestions will be appreciated and codes as well.
Cheers.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Gabriel
If you've never used JDBC before there is a lot to explain in it to make you proficient in it, a good starting place is the JDBC tutorial
IF you already know JDBC, is there a specific place you're stuck? Post some code and we can help you out.
Dave


Dave
schandu999
Greenhorn

Joined: Feb 07, 2002
Posts: 9
Hi,
For this use Callable cstmt as
CallableStatement cstmt = null;
or
CallableStatement cstmt = conn.prepareCall("{call Proc_name(?,?,?,?)}");
then set the IN params in the proc using set methods as setInt ,setString
and out as
cstmt.registerOutParameter(2, java.sql.Types.INTEGER);
(here 2 -> parameterInedex and java.sql.Types.INTEGER as -> sql type)
there are methods also registering the out parameters see it in java doc
then execute the proc as
cstmt.execute();
In the end close cstmt , conn in the finally block
thanks
champak
Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
Thanks guys , though i have been using JDBC
for a while mainly the Statement Object.
But,the JDBC code was working fine,but the problem was the Stored procedure was created using
the DBA right on the Oracle database,so the
error message i got was:
pls-00201: stored procedure header must be declared
ora-06550 : line 1, column 7
pl/sql: statement ignored
My CallableStatement got executed correctly
after the user right was granted.
[ February 19, 2002: Message edited by: Gabriel Fox ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem using Callable Statement
 
Similar Threads
How to call stored procedure from Entity Manager if there is out parameter in stored procedure.
@NamedNativeQuery and choosing the correct resultClass
how to pass parameters in stored procedure by using text boxes in jsp
how to call stored procedure and also get parameters from the web page
how to call stored procedure and also get parameters from the web page