This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DB2 stored proc returning a results set

 
Richard Olmstead
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'd like to return a results set from a DB2 stored proc, and have tried this:

String sql = " {call G714.GDDPOHP2(? , ?) } " ;
CallableStatement callable = conn.prepareCall( sql );

callable.setString(1, "76021592220080101");

(...both parms are defined to DB2 as INOUT ...)
callable.registerOutParameter(1, java.sql.Types.CHAR);
callable.registerOutParameter(2, java.sql.Types.CHAR);

What makes it tricky is, the stored procedure's cursor is defined WITH RETURN, and parameter #2 isn't the result set, but error messages sent back.
I'll execute, this way,

callable.execute();

and have an error, here:
ResultSet rs = (ResultSet)callable.getObject(1);

I'd like to have the data available, like so:
while (rs.next()) {
System.out.println(
rs.getString(1) + "\t" +
rs.getString(2) + "\t" +
rs.getString(3) ) ;
}
Would anyone know how to receive the result-set data?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic