我配置了一个运行良好的 CloudBees Run@cloud 实例,但是在一段时间不活动后它被停用,然后似乎连接池没有正确刷新。
当我返回该站点时,前几个请求超时:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 4,746,680 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
sun.reflect.GeneratedConstructorAccessor86.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3092)
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2978)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3526)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:5022)
org.apache.tomcat.dbcp.dbcp.DelegatingConnection.setAutoCommit(DelegatingConnection.java:371)
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.setAutoCommit(PoolingDataSource.java:328)
org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:87)
org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1473)
我使用 cloudbees-web.xml 文件中配置的数据源通过 JNDI 进行连接,如下所示:
<resource name="jdbc/myapp" auth="Container" type="javax.sql.DataSource">
<param name="username" value="myuser" />
<param name="password" value="mypass" />
<param name="url" value="jdbc:cloudbees://myurl />
</resource>
是否缺少一些配置,或者这是服务器中连接池配置的错误?