You might consider adding some additional properties to allow it to try and reconnect. For example:
dataSource_target {
dialect = org.hibernate.dialect.MySQLInnoDBDialect
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
username = "bla"
password = "bla"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
I suggest you alter the properties to suit your needs. This however, will not address the issue of the database not being available when the application is started.
To avoid that, you have to get away from using Grails data sources. In that case you would need to define your datasource in your service that is making the calls to the database.
def db = [
url:'jdbc:hsqldb:mem:testDB',
user:'sa',
password:'',
driver:'org.hsqldb.jdbc.JDBCDriver'
]
def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
Of course, modify this to suit your needs. You may even pull these settings from Config.groovy instead of hard coding them (highly recommended).