Shanmuganathan(Shan) Srinivasan

Monday, May 12, 2014

Grails Datasource connection issue

Environment:
  Grails on tomcat deployed as war

Reported Issue:
   Application looses database connections every 3-5 days

Error Messages:
com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667)

ERROR Could not toggle autocommit (JDBCTransaction.toggleAutoCommit)
com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed

Cause:
     Once a Database Connection Reset or Network disconnection happens, application does not recover DB connections automatically. Throws either Connection Reset or Connection is closed error  The DB connections are not pooled by default.

Solution:
dataSource {
    driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    dialect = "org.hibernate.dialect.SQLServer2008Dialect"
     pooled = true
}

Also use other configurations related connection pooling as specified in Grails documentation


0 Comments:

Post a Comment

<< Home