Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

DB2 stored proc returning a results set  RSS feed

Richard Olmstead
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,


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

I'd like to have the data available, like so:
while ( {
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
Boost this thread!