-->
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.  [ 1 post ] 
Author Message
 Post subject: could not execute query
PostPosted: Wed Aug 23, 2006 4:32 am 
Regular
Regular

Joined: Mon May 22, 2006 8:32 am
Posts: 67
Hi all,

i try to execute the following statement to obtain a user from my Sybase-DB:

Code:
public User getUserByName(String screenName) {
User user = null;
      Session lsession = getCurrentSession();
     
      try{
         log.info("Trying to login user...");
         List users = lsession.createQuery("from User as user where user.inhouseLogin = ?")
          .setString(0, screenName)
           .list();
     
         Iterator it = users.iterator();
     
         while (it.hasNext()){
            user = new User();
            user = (User) it.next();
            log.info("Obtaining user from DB...");
         }
         return user;
      }
      finally{
         lsession.close();
      }
     
   }


But i git the following error:
Code:
org.hibernate.exception.GenericJDBCException: could not execute query
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:1518)
   at org.hibernate.loader.Loader.list(Loader.java:1498)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1253)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
...

Caused by: java.sql.SQLException: JZ0S2: Statement object has already been closed.
   at com.sybase.jdbc3.jdbc.ErrorMessage.raiseError(ErrorMessage.java:565)
   at com.sybase.jdbc3.jdbc.SybStatement.checkDead(SybStatement.java:2051)
   at com.sybase.jdbc3.jdbc.SybStatement.close(SybStatement.java:487)
   at com.sybase.jdbc3.jdbc.SybStatement.close(SybStatement.java:475)
...


Can anybody help? Why is this wrong? Any other DB in my application uses similar code to get records from db...

_________________
Regards,
ak


Please don't forgat to rate


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

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.