I have an interesting problem that I could not solve. I am using Play! 2.0.4 and using the combined BoneCP connection pool to connect to the database. However, for some reason, BoneCP continues to return closed connections.
Database Server: Amazon RDS MySQL 5, default timeout settings (which should be 8 hours...)
My Datasource configuration is as follows:
db.default.driver=com.mysql.jdbc.Driver db.default.url="jdbc:mysql://{server}/{schema}?autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8" db.default.partitionCount=4 db.default.idleConnectionTestPeriod=2 minutes
I assumed that setting idleConnectionTestPeriod for 2 minutes would probably prevent BoneCP from returning closed connections, but that is not the case.
Each time so, I get the following stack trace in my logs:
Exception in thread "pool-6-thread-25" java.sql.SQLException: Connection is closed! at com.jolbox.bonecp.ConnectionHandle.checkClosed(ConnectionHandle.java:350) at com.jolbox.bonecp.ConnectionHandle.setReadOnly(ConnectionHandle.java:1089) at play.api.db.BoneCPApi$$anon$1.onCheckOut(DB.scala:328) at com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:514) at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:114) at play.api.db.DBApi$class.getConnection(DB.scala:64) at play.api.db.BoneCPApi.getConnection(DB.scala:273) at play.api.db.DB$$anonfun$getConnection$1.apply(DB.scala:129) at play.api.db.DB$$anonfun$getConnection$1.apply(DB.scala:129) at scala.Option.map(Option.scala:133) at play.api.db.DB$.getConnection(DB.scala:129) at play.api.db.DB.getConnection(DB.scala) at play.db.DB.getConnection(DB.java:50) at play.db.DB.getConnection(DB.java:43) at play.db.DB.getConnection(DB.java:29) at com.edatasource.inboxtracker.tasks.TrackSiteEventActionTask.run(TrackSiteEventActionTask.java:23) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
Does anyone know how I can fix this problem? Currently, I had to wrap DB.getConnection () in a try / catch and just catch the exception thrown by BoneCP and try again until I get the correct connection. It doesn't seem to be necessary.
Thanks for any help.
source share