我有一个 Scala 代码,使用 scalalikejdbc 连接并在 MySQL 中执行插入操作。代码运行良好约 2-3 小时,然后抛出
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
我的连接设置如下:
val url = "jdbc:mysql://www.domain.com:3306/schema";
val settings = ConnectionPoolSettings(
initialSize = 1,
maxSize = 2,
connectionTimeoutMillis = 100000L,
validationQuery = "select 1 from dual");
ConnectionPool.add('dbval, url, username, pwd, settings);
发生这种情况的任何原因以及如何解决?
相关分类