-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Db2 stored procedure which returns resultset not working
PostPosted: Mon Jul 04, 2011 10:01 am 
Newbie

Joined: Tue Jun 21, 2011 1:51 am
Posts: 4
Hi All,
I am trying execute stored procedure which returns resultset using hibernate named query approach.
But it's throwing exception saying:

INFO: Not binding factory to JNDI, no JNDI name configured
Hibernate: { call bankfusion.TestSpResult_SELECT(?) }
Jul 4, 2011 7:24:00 PM org.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: -313, SQLState: 07004
Jul 4, 2011 7:24:00 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: DB2 SQL error: SQLCODE: -313, SQLSTATE: 07004, SQLERRMC: null
could not execute query
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2231)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at roseindia.tutorial.hibernate.StoredProcExample.main(StoredProcExample.java:44)
Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -313, SQLSTATE: 07004, SQLERRMC: null
at com.ibm.db2.jcc.b.sf.d(sf.java:1396)
at com.ibm.db2.jcc.c.jb.l(jb.java:367)
at com.ibm.db2.jcc.c.jb.e(jb.java:92)
at com.ibm.db2.jcc.c.w.e(w.java:72)
at com.ibm.db2.jcc.c.cc.h(cc.java:203)
at com.ibm.db2.jcc.b.sf.q(sf.java:1363)
at com.ibm.db2.jcc.b.tf.d(tf.java:2388)
at com.ibm.db2.jcc.b.uf.Z(uf.java:159)
at com.ibm.db2.jcc.b.uf.execute(uf.java:142)
at org.hibernate.dialect.DB2Dialect.getResultSet(DB2Dialect.java:334)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:215)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1805)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
... 7 more
And
Here is my user.hbm.xml file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="roseindia.tutorial.hibernate.User">
<id name="bfnamepk"/>
<property name="bfpassword"/>
<property name="bflanguagelocale"/>
<property name="bfpasswordexpiryind"/>
</class>
<sql-query name="TestSpResult_SELECT" callable="true">
<return class="roseindia.tutorial.hibernate.User">
</return>
{ call bankfusion.TestSpResult_SELECT(?) }
</sql-query>
</hibernate-mapping>



And my DB2 stored Procedure is:
create or replace procedure Bankfusion.TestSpResult_Select (OUT resultset VARCHAR(2048))
begin

declare mycur cursor for

select BFNAMEPK, BFPASSWORD, BFLANGUAGELOCALE, BFPASSWORDEXPIRYIND from bankfusion.bftb_user;

open mycur;
Fetch mycur into resultset;
close mycur;
end


Can anyone help me please? Same thing works fine oracle(oracle stored procedure syntax is different).


Top
 Profile  
 
 Post subject: Re: Db2 stored procedure which returns resultset not working
PostPosted: Mon Jul 04, 2011 11:24 am 
Newbie

Joined: Tue Jun 21, 2011 1:51 am
Posts: 4
Can any one please help me in this???
I am not able to make out is it a Stored Procedure problem OR Hibernate side problem?

Thanks,
Hukum


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.