• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem using Callable Statement

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic