3

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

2
  • I don't think this is a Spring Data related issue. Would you mind adding the datasource configuration or your general JPA infrastructure setup? Commented Apr 22, 2012 at 9:10
  • Here is my database configuration: <Resource auth="Container" defaultAutoCommit="false" defaultTransactionIsolation="2" driverClassName="com.mysql.jdbc.Driver" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/projectDB" password="password" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/database" username="user" validationQuery="SELECT 1 from dual"/> Commented May 9, 2012 at 4:52

1 Answer 1

2

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 :)

Sign up to request clarification or add additional context in comments.

1 Comment

Here's another article i found helpful while investigating the issue.: info.michael-simons.eu/2011/11/21/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.