pamobo0609
pamobo0609

Reputation: 812

Connection to database lost after several hours in Grails war

I'm having a rare issue with a war I deployed, and it's connection to the database server (MySQL), here's the thing:
I made the tomcat config like this:

<Resource name="jdbc/gimnasioBackend" auth="Container" type="javax.sql.DataSour$
               maxTotal="100" maxIdle="30" maxWaitMillis="10000"
               username=["username"] password=["password"] driverClassName="com$
               url="jdbc:mysql://localhost:3306/[databaseName]"/>

And is connecting just fine, but the thing is that every day I come to check the server status, and also test the pages in it, I can't login. If I restart the server (which is not recommended, judging what I've red), I can login (using spring security) again, but not for long... The situation is complicated, mainly because it's already in production, and is holding a backend for an app..
Thanks in advance!

Note: There's more than one web app in this tomcat, all of them working fine.

Upvotes: 0

Views: 337

Answers (1)

GUL
GUL

Reputation: 1195

I had a similar issue with grails DataSource and with tomcat resource configuration connecting to an Oracle database and I resolved adding

validationQuery="SELECT 1 FROM DUAL"
validationQueryTimeout=3
validationInterval=15000

If the problem is due to connection against database lost I suppose you can try adding those properties. Validation query for mysql should be select 1 instead of select 1 from dual

Upvotes: 1

Related Questions