jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes Resultset returns null from a srored procedure in db2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Resultset returns null from a srored procedure in db2" Watch "Resultset returns null from a srored procedure in db2" New topic
Author

Resultset returns null from a srored procedure in db2

Aravind Bhat
Ranch Hand

Joined: Jun 16, 2006
Posts: 32
Hi All ,
I am trying to call a db2 stored proc with cursor open from my java code but it always returns me null results though it executes fine when I call the procedure from the command line

Java code....................

CallableStatement stmt3 = EyeHibernateApp.getHibernateSession().connection().prepareCall("{call answers_select_id( ? )}");

stmt3.setString(1,20);

stmt3.execute();



ResultSet rs1 = stmt3.getResultSet();

System.out.println("rs1 " + rs1); --> returns null

--------------------------------------------------------------
procedure-------------


CREATE PROCEDURE answers_select_id (IN question_id bigint )
P1:BEGIN
DECLARE cursor1 CURSOR WITH RETURN TO CLIENT FOR
SELECT a.answer_id from answers as a where a.question_id = question_id;
open cursor1;
END P1;


I am using the same java code with mysql stored procs . It works fine there but I assume open cursors in db2 stored proc is causing the problem . If I can help it , I need to maintain the same java code for mysql ad db2 . Please help me ...

Thanks,
Av~
 
 
subject: Resultset returns null from a srored procedure in db2
 
Similar Threads
Stored procedure which returns array
getting ResultSet from Java Stored Procedure
How to return a cursor in DB2
Error :java.sql.SQLException: Invalid column index
Proble Getting resultset using CallableStatement WAS 6