Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Calling Oracle stored procedures from JDBC

Calling Oracle stored procedures from JDBC

From: Manish <manish.shah_at_emagine-int.com>
Date: 27 Sep 2001 19:50:18 -0700
Message-ID: <18b0424d.0109271850.3f69bbac@posting.google.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US