Grails/Tomcat/MySQL stale connection error, even when using JNDI? -
i have couple of grails 1.3.3 application running on tomcat 6.0.18. i'm aware of database connection staleness issue when using default grails datasource (connection gets killed after period of inactivity), switched jndi provided tomcat.
the first app deployed has never had stale database connection problems. deployed second app same server same jndi datasource configuration, , while first continues work fine, second app gets connection timeout error after 8 or hours of inactivity. (after error connection gets refreshed , works fine again)
the datasources defined in tomcat's context.xml follows:
<resource name="jdbc/firstds" auth="container" type="javax.sql.datasource" maxactive="100" maxidle="30" maxwait="10000" username="user1" password="password1" driverclassname="com.mysql.jdbc.driver" url="jdbc:mysql://localhost:3306/firstapp" /> <resource name="jdbc/secondds" auth="container" type="javax.sql.datasource" maxactive="100" maxidle="30" maxwait="10000" username="user2" password="password2" driverclassname="com.mysql.jdbc.driver" url="jdbc:mysql://localhost:3306/secondapp" />
both of apps use jndi datasource in datasource.groovy file follows (everything same, except jndiname):
datasource { pooled = false } ... environments { ... production { datasource { dbcreate = "update" jndiname = "java:comp/env/jdbc/firstapp" } } }
the only difference i'm aware of between these 2 situations working app uses myisam tables, while non-working app uses innodb tables. has experienced issue innodb , tomcat connection pooling? may try switching myisam if can't find else try.
for mysql , grails it's best practice have validation query on db pool. might append definitions:
validationquery="select 1"
see http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#jdbc_data_sources
Comments
Post a Comment