File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes JDBC and stored procedure - Please Help!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC and stored procedure - Please Help!!!" Watch "JDBC and stored procedure - Please Help!!!" New topic
Author

JDBC and stored procedure - Please Help!!!

sarah Marsh
Ranch Hand

Joined: Mar 06, 2001
Posts: 282
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

Joined: Jun 15, 2001
Posts: 12
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

Joined: Mar 06, 2001
Posts: 282
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC and stored procedure - Please Help!!!