File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes calling stored procedure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "calling stored procedure" Watch "calling stored procedure" New topic

calling stored procedure

Sanjeev Kaushik
Ranch Hand

Joined: Aug 01, 2002
Posts: 105
I am calling a stored procedure(Oracle 9.2.04) from Java. My offshore team tested this code using stmt.registerOutParameter and it worked for them. Now at client site, it did not work. I changed it by setInt and it worked. Please let me know if it is a known bug.
CallableStatement stmt=null;
try {
stmt= conn.prepareCall("call MoveToTemp(?)");
//stmt.registerOutParameter(1, Types.INTEGER, aiApplicationId);
stmt.setInt(1, aiApplicationId);
} catch (Exception ex) {

Sanjeev Kaushik
M Givney

Joined: Sep 24, 2003
Posts: 25
It's difficult to say without seeing the stored procedure's signature, but there are a couple of things you can check.
The registerOutParameter() method is used to capture parameters that are defined as OUT parameters in the stored procedure. See if the procedure has an OUT parameter as the first parameter.
Also, I would guess if there is a OUT parameter, they would try to use the out parameter...check down in the code a little you see any calls that look like: int <varname> = stmt.getInt(1); ?
The code you commented out:
stmt.registerOutParameter(1, Types.INTEGER, aiApplicationId);
will compile but will fail at runtime if there isn't an OUT param in the proc @ position 1. This code tells the statement that there is an Out param in position 1 of type integer and with a scale of whatever aiApplicationId equates to.
Hope that helps.
[ April 20, 2004: Message edited by: M Givney ]
I agree. Here's the link:
subject: calling stored procedure
It's not a secret anymore!