Our application runs on Grails and we have MS SQL Database. We have an issue with our client. The problem is that their DB server suddenly goes down due to some reason or the other. It's only momentary and usually comes back in a couple of minutes or so. Whenever it is down and the users try to access the application, they see this error:
Caused by: org.hibernate.TransactionException: JDBC begin failed:
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:92)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
... 84 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.checkClosed(SQLServerConnection.java:388)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.getAutoCommit(SQLServerConnection.java:
I have googled and found a couple of links:
MySQL Connection Timeout Issue - Grails Application on Tomcat using Hibernate and ORM
http://andrzejgrzesik.info/2011/12/18/grails-automatically-reconnect-to-mysql-datasource/
But in both the above cases, it seems the application usually comes up on UI after the users attempt a few times. However, in my case, the UI never comes up and we continue to see the same errors despite after bringing the DB back. It's only after we restart the grails instance ( i.e tomcat ) that we see the application back.
Currenlty, our DataSourceConfig is pretty staright forward:
dataSource {
dialect = org.hibernate.dialect.SQLServerDialect
driverClassName = 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
username = 'user'
password = 'P@SSWorD'
url = 'jdbc:sqlserver://hostName;DatabaseName=dbName;instanceName=instanceName'
dbCreate = 'update' // Deliberately kept in update mode due to some reasons. Please advise if it has to be changed as well.
}
Appreciate your help as this issue is on our neck right now.