| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> JAVA CallableStatement
I have been unsuccessful retrieving an OUT
parameter from a stored procedure using a
registerOutParameter with a CallableStatement.
The stored procedure is updating the table
correctly it is just not returning the OUT
paramerter.
Any suggestions.
java.sql.Connection conn = null;
java.sql.Statement stmt = null;
java.sql.ResultSet rs = null;
int statusMessage = 0;
try{
InitialContext ctx = null;
DataSource ds = null;
String sql = "{call
", "+this.price+", ?)}";
System.out.println(sql);
ctx = new InitialContext();
ds =
(DataSource)ctx.lookup("jdbc/db1");
conn = ds.getConnection();
java.sql.CallableStatement cstmt =
conn.prepareCall(sql);
cstmt.registerOutParameter(1,
java.sql.Types.INTEGER);
cstmt.execute();
statusMessage = cstmt.getInt(1);
conn.close();
}
catch(Exception e){
//Any error is grounds for rollback
try{
System.out.println(e);
//conn.rollback();
}
catch(Exception ignored){
System.out.println("Place
Order Failed");
}
}
finally {
//Clean Up
try{
if (conn != null)
conn.close();
}
catch (SQLException ignored) {}
}
return statusMessage;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Wed Nov 10 1999 - 16:24:27 CST
![]() |
![]() |