Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with callableStatement()

Status
Not open for further replies.

penciled

Programmer
Sep 4, 2001
5
0
0
US
I have a PL/SQL procedure that SELECTs lists of data from several tables. I want to be able to use this with JSP. I've read about people using CURSORS to retrieve multiple tuples from database queries. I'm new to cursors and callableStatements.
Can someone please walk me through (examples would be nice) this process?
My procedure is fairly basic. I give it a userID and/or location that are used in the WHERE clause and it will list all the information for that user and/or location.
I think this is how it's supposed to be done-> but I'm not positive:
callableStatement cs = con.prepareCall ( "{ call myProc ( ?,?, ? )}" );
cs.registerOutParameter( 1, CURSOR );
cs.setString( 2, uNum );
cs.setString( 3, location );
cs.execute();
resultSet rs = cs...?
while( rs.next() ) {
//List data
}
Is this right?
 
I was told that I needed to do this:
ResultSet rs = ((OracleCallableStatement)cs).getCursor(1);
...so I added the Oracle stuff- I had to include <%@ page import=&quot;oracle.jdbc.driver.*&quot; %> as well, but now I'm getting several errors like this one:
C:\Tomcat\work\localhost\examples\jsp\Henry\telcom\tReports\tCreateReport$jsp.java:0: The method oracle.jdbc2.Clob getClob(int) / getRef(int) / getBlob(int) / getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
package org.apache.jsp;
^
I tried a few other things, but I'm not sure what I'm supposed to do with that. Any ideas?
Here's my code:
cs = con.prepareCall ( &quot;{ call myProc ( ?,? )}&quot; );
cs.registerOutParameter( 1, OracleTypes.CURSOR );
cs.setString( 2, uNum );

cs.execute();
rs = ( ( OracleCallableStatement ) cs ).getCursor( 1 );
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top