File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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 Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem using Callable Statement" Watch "Problem using Callable Statement" New topic

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.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
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.


Joined: Feb 07, 2002
Posts: 9
For this use Callable cstmt as
CallableStatement cstmt = null;
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
In the end close cstmt , conn in the finally block
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 ]
Don't get me started about those stupid light bulbs.
subject: Problem using Callable Statement
It's not a secret anymore!