0

I am executing a stored procedure in Java using the old school way:

CallableStatement cs = 
con.prepareCall("schema.procedure("?,?,?,?");
cs.setString(1, "f");
cs.setString(2, "f");
cs.registerOutParameter(3, Types.CHAR);
cs.registerOutParameter(4, Types.CHAR);
cs.execute();
System.out.println(cs.getString(3));

I can retrieve the output columns, but the procedure also returns other results as part of cursor, which i can retrieve using :

ResultSet rs= cs.executeQuery()
while (rs.next()) {
for(int i=1;i<=rs.getMetaData().getColumnCount();i++){
rs.getString(i)

My question is, can i retrieve both output and the cursor in the same statement ? Thanks,

Parameswar
  • 1,951
  • 9
  • 34
  • 57
  • See [java code make a stored procedure return a resultset in DAO layer](https://stackoverflow.com/q/35612566/5221149) – Andreas Sep 24 '18 at 19:03

1 Answers1

0

thanks all , finally this worked, if there is any issue with the approach, please suggest:

CallableStatement cs = 
con.prepareCall("schema.procedure("?,?,?,?");
cs.setString(1, "f");
cs.setString(2, "f");
cs.registerOutParameter(3, Types.CHAR);
cs.registerOutParameter(4, Types.CHAR);
cs.execute();
System.out.println(cs.getString(3));
ResultSet rs = cs.getResultSet();
while (rs.next()) {
    for(int i=1;i<=rs.getMetaData().getColumnCount();i++){
        rs.getString(i)
    }
}
Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78
Parameswar
  • 1,951
  • 9
  • 34
  • 57