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...