File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem using Callable Statement

 
Gabriel Fox
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
schandu999
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic