• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JDBC and stored procedure - Please Help!!!

 
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All:
How to make a call to a Stored Procedure in
an Java application using JDBC?
Is there any links on the web?
Thanks in advance,
Sarah
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CallableStatement stmt = con.prepareCall(
"{call pkg.proc(?,?)}");
stmt.setInt(1,myInt);
stmt.registerOutParameter(1,OracleTypes.CURSOR);
stmt.execute();
ResultSet rs = (ResultSet)stmt.getObject(2);

This is a fairly basic example. It assumes that you are connected and that the username used to get the connection has permissions to execute the stored procedure. Also, I assumed that you are using oracle. A good reference is
http://www.csee.umbc.edu/help/oracle8/java.815/a64685/basic5.htm

Hope it helps
 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi mathew,
Thank you very much for your answer. Actually,
I'm going to access DB2. The calling syntax
should be depent on the version of JDBC that
I use, right?
Sarah
 
It's a tiny ad. At least, that's what she said.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic