I have below datasource config in grails.
dataSource_staging_oracle {
dbCreate = "none"
pooled = true
url = "jdbc:oracle:thin:@//my-box-oracle.com:1521/DB1"
driverClassName = "oracle.jdbc.OracleDriver"
username = "USER_1"
password = "encryptedpassword"
passwordEncryptionCodec = PropertiesCodec
}
dataSource_prod_oracle {
dbCreate = "none"
pooled = true
autoReconnect = true
url = "jdbc:oracle:thin:@//my-oracle-prod-box.com:1521/DB2"
driverClassName = "oracle.jdbc.OracleDriver"
username = "user_2"
password = "encrypted_password"
passwordEncryptionCodec = PropertiesCodec
}
Application is able to fetch the DB connection and work fine. However after 1-2 hours of processing, I see connection closed exceptions.
ERROR util.JDBCExceptionReporter - Closed Connection
I believe this has to do with datasource config properties. What grails settings help me in refreshing the connections? I already have set autoReconnect
and pooled
to true
I use grails 2.3.3
Below config helped me fix my problem.
dataSource_staging {
dbCreate = "none"
pooled = true
autoReconnect = true
url = "jdbc:oracle:thin:@//my-box-oracle.com:1521/DB1"
driverClassName = "oracle.jdbc.OracleDriver"
username = "USER_1"
password = "encryptedpassword"
passwordEncryptionCodec = PropertiesCodec
properties {
validationQuery = "SELECT 1 FROM DUAL"
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
maxAge = 10 * 60000
maxWait = 10000
maxIdle = 25
maxActive = 50
initialSize = 5
}
}