This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC 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
Bookmark "calling stored procedure" Watch "calling stored procedure" New topic
Author

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);
stmt.execute();
stmt.close();
} catch (Exception ex) {
ex.printStackTrace();
}
============================================================


Sanjeev Kaushik
M Givney
Greenhorn

Joined: Sep 24, 2003
Posts: 25
Sanjeev,
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 ways..do 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.
Regards,
Matt
[ April 20, 2004: Message edited by: M Givney ]
 
jQuery in Action, 2nd edition
 
subject: calling stored procedure