How to call DB2 procedure using Hibernate

Hi
  I am trying to call DB2 procedure from Hibernate.
  I could not get data. The resultset is returned as null.
  Could anyone help.

Thanks

Hibernate Code
===============
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
Transaction tx = session.beginTransaction();
try {
CallableStatement stmt = session.connection().prepareCall("{? = call SAMPLE.PROCEDURE3()}");
boolean statusFlag = stmt.execute();
tx.commit();
ResultSet rs = stmt.getResultSet();
System.out.println("Test1.main() statusFlag is: "+statusFlag);
}
catch(Exception e)
{
if(tx != null) {
tx.rollback();
}
System.out.println(e.getMessage());
}
finally{
if(session!=null && session.isOpen())
session.close();
}
 
DB2 Procedure
==============
CREATE PROCEDURE SAMPLE.PROCEDURE3 (  )
P1: BEGIN
    DECLARE get_Bank CURSOR WITH RETURN  FOR
    	SELECT ID, BANK_NAME FROM SAMPLE.BANKING;
	OPEN get_Bank;
END P1
 
Data in DB2
=========
ID,BANK_NAME
------------------
1,HDFC
2,CITI
3,AXIS
4,UTO
5,SC
6,SBI
1,HDFC
2,CITI
3,AXIS
4,UTO
5,SC
6,SBI

Open in new window

ysgantaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ysgantaAuthor Commented:

 Resolved.
 The procedure needs to specify the number of resulsets.

example:
CREATE PROCEDURE SAMPLE.PROCEDURE3 (  )
RESULT SETS 1
P1: BEGIN
DECLARE get_Bank CURSOR WITH RETURN  FOR
SELECT ID, BANK_NAME FROM SAMPLE.BANKING;
OPEN get_Bank;
END P1
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.