Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#12 Statement object has already been closed

closed
nobody
None
5
2005-05-11
2005-05-09
Thomas A Beck
No

When using Hibernate, c3p0 and on some platforms only,
we get the following error:

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)
at com.tmp.deal.business.HbMgr.getAll(HbMgr.java:55)
at
com.tmp.tmp.business.BusinessSessionFactoryTest.testBusinessSessionFactory(BusinessSessionFactoryTest.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
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)
at
com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.close(NewProxyPreparedStatement.java:1674)
at
org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:393)
at
org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:195)
at
org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:212)
at
org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:141)
at org.hibernate.loader.Loader.doQuery(Loader.java:408)
at
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
at org.hibernate.loader.Loader.doList(Loader.java:1515)
... 21 more

When we use another connection pool instead, it works fine.

Discussion

  • Steve Waldman
    Steve Waldman
    2005-05-09

    Logged In: YES
    user_id=175530

    hi... can you tell me 1) what version of c3p0 you are using;
    2) whether you are using Statement caching (i'm guessing not
    from the above); and 3) is this error an occasional thing
    that shows up in your logs, or something that reliably
    happens every time some operations are performed? (You might
    want to send along c3p0's initialization config dump too.)
    I'm thinking about this, but the extra info would help.

    Thanks!

     
  • Thomas A Beck
    Thomas A Beck
    2005-05-11

    Logged In: YES
    user_id=521771

    Oh, sorry:
    1) the stack:
    Hibernate version 3.0 (31.3.2005)
    c3p0 version 0.8.5
    jconnect version 6.0.0
    ASE 12.5.2

    2) Do not know, just default hibernate settings

    3) On each database access with the stack above. For
    example in hibernate with
    session.createCriteria(MyClass.class), criteria.list

    If instead we used the jtds jdbc driver, this happened only
    occasionally.

    Apparently this does not happen anymore when using Hibernate
    3.0.3 with c3p0 0.8.5.2.

    We do not need help on this issue, we do not use this stack
    anymore. We cannot do additional tests for that.
    This ticket is just for your information, hope useful.

    Thanks
    Regards.

     
  • Steve Waldman
    Steve Waldman
    2005-05-11

    • status: open --> closed
     
  • Steve Waldman
    Steve Waldman
    2005-05-11

    Logged In: YES
    user_id=175530

    OK. It sounds like this was the statement caching bug fixed
    as of c3p0-0.8.5.2, in which cached Statements were
    erroneously closed. It sounds like you aren't seeing the
    problem under c3p0-0.8.5.2 (and this is fixed in the 0.9.0
    series fixes as well). I'll consider the issue resolved
    unless I hear otherwise from you. Thanks.