Dhruv
Dhruv

Reputation: 10703

Exception in Hibernate 'Cannot Release Connection'?

I have used Spring DATA JPA in my application, which is wrapper over hibernate. While interaction with database at one point I am getting expection

Caused by: org.hibernate.exception.GenericJDBCException: Cannot release connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
    at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:478)
    at org.hibernate.jdbc.ConnectionManager.aggressiveRelease(ConnectionManager.java:429)
    at org.hibernate.jdbc.ConnectionManager.afterStatement(ConnectionManager.java:304)
    at org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:572)
    at org.hibernate.jdbc.AbstractBatcher.closeStatement(AbstractBatcher.java:291)
    at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:307)
    at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:1967)
    at org.hibernate.loader.Loader.doQuery(Loader.java:802)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
    at org.hibernate.loader.Loader.doList(Loader.java:2533)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    at org.hibernate.loader.Loader.list(Loader.java:2271)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)

connection handling in hibernate is the internal handling we don't explicitly release or close the connection.

I can't understand how to resolve this issue..

Upvotes: 3

Views: 9291

Answers (1)

Dhruv
Dhruv

Reputation: 10703

Finally I got the solution. I solved this problem by setting some additional configuration for by database.

Here is the detailed link: http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html

In nutshell ("testOnBorrow”, “testOnReturn”, “testWhileIdle”) these are the parameters I played with to remove above exception. Above exception show at some point of time our database connection object get invalidated somehow. But these setting helps us to keep check on our database connection.

Cheers :)

Upvotes: 2

Related Questions