I have a project that used a grails framework 3.X and Oracle DB, and the project is deployed on tomcat 9.0.X.
There is a DB connection problem on the project that the DB connection is interrupted and then the project can't reconnect with the DB automatically when the connection, firewall or any network configuration between the project and DB has changed; or the settings of the DB have changed or the DB has restarted. Because of that, nowadays, I manually redeploy the project on a tomcat sever when this problem is happening.
In order to fix the problem, I tried many changes, but the issue hasn't disappeared yet. For example, I changed properties of a dataSource configuration on application.yml and tried different versions of OJDBC driver.
The interrupted connection can reconnect automatically when I changed the value of "pool" to false from true on application.yml. But, I think that "pool: false" configuration has negative consequences because a DB connection operation is an expensive. For instance, to reach a maximum connection limit, ...
So, my question is that how to do an automatic pooled reconnection on an Oracle DB and a grails project when a DB connection is interrupted?
My current configuration on application.yml (maybe some properties are changed because of the test):
dataSources:
dataSource:
pooled: true
jmxExport: true
driverClassName: oracle.jdbc.OracleDriver
environments:
development:
dataSources:
dataSource:
logSql: false
dbCreate: update
url: jdbc:oracle:thin:@localdomain:1521/test
username: test
password: test
properties:
maxActive: 50
maxIdle: 25
minIdle: 1
initialSize: 5
numTestsPerEvictionRun: 3
maxWait: 1000
testOnBorrow: true
testWhileIdle: true
testOnReturn: true
minEvictableIdleTimeMillis: 1000
timeBetweenEvictionRunsMillis: 1000
validationQuery: SELECT 1 FROM DUAL
validationQueryTimeout: 5
validationInterval: 5
removeAbandoned: true
removeAbandonedTimeout: 5
production:
dataSources:
dataSource:
dbCreate: none
jndiName: "java:comp/env/testDs"
properties:
maxActive: 50
maxIdle: 25
minIdle: 1
initialSize: 5
numTestsPerEvictionRun: 3
maxWait: 1000
testOnBorrow: true
testWhileIdle: true
testOnReturn: true
minEvictableIdleTimeMillis: 1000
timeBetweenEvictionRunsMillis: 1000
validationQuery: SELECT 1 FROM DUAL
validationQueryTimeout: 5
validationInterval: 5
removeAbandoned: true
removeAbandonedTimeout: 5
you can try set validationQuery properties is null, check validationQuery properties is confilct other properties.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.