Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Calling Oracle stored procedures from JDBC
Hi,
I'm using Weblogic 6.1 application server with Oracle 8i database server. I have to call a stored procedure that returns a cursor. The only way I've been able to get this to work is as follows:
import java.sql.*
import javax.sql.*
import weblogic.jdbc.common.OracleCallableStatement;
// get the data source from the app server
StringBuffer sql = "{?=call TEST.SELECT_DATA(?)}";
Connection con = ds.getConnection();
OracleCallableStatement st = (OracleCallableStatement)
con.prepareCall(sql);
// register the returned cursor
st.registerOutParameter(1, Types.OTHER);
// set in parameters
st.setInt(2, 999);
st.execute();
ResultSet rs = st.getResultSet(1);
Now, unless I'm missing something, this is the only way to return a resultset from an Oracle stored procedure. This implies that my code is now Oracle-specific, as I need to use the OracleCallableStatement to bind the cursor to a ResultSet. Is there another way of calling an Oracle stored procedure that returns a cursor without having to make my code Oracle-specific? This is what I would except from J2EE, but unless I am mistaken it isn't possible.
Thanks,
Manish
Received on Thu Sep 27 2001 - 21:50:18 CDT