• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC and stored procedure - Please Help!!!

 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • 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
 
mathew Jackson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic