报错信息:
com.mysql.jdbc.CommunicationsException: The last packet successfully received from the server was58129 seconds ago.The last packet sent successfully to the server was 58129 seconds ago, which is longer than the server configured value of 'wait_timeout'. You
should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
查了一下,原来是mysql超时设置的问题
如果连接闲置8小时 (8小时内没有进行数据库操作), mysql就会自动断开连接, 要重启tomcat.
解决办法:
一种. 如果不用hibernate的话, 则在 connection url中加参数: autoReconnect=true
jdbc.url=jdbc:mysql://ipaddress:3306/database?autoReconnect=true&autoReconnectForPools=true
二种。用hibernate的话, 加如下属性:
<property name="connection.autoReconnect">true</property>
<property name="connection.autoReconnectForPools">true</property>
<property name="connection.is-connection-validation-required">true</property>
三。要是还用c3p0连接池:
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">0</property>
<property name="hibernate.c3p0.timeout">0</property>
<property name="hibernate.c3p0.validate">true</property>
四。修改mysql配置文件属性:
MySQL服务器默认的“wait_timeout”是28800秒即8小时,意味着如果一个连接的空闲时间超过8个小时,MySQL将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。
只能修改MySQL的参数了,wait_timeout最大为31536000即1年,在my.cnf中加入:
[mysqld]
wait_timeout=31536000
interactive_timeout=31536000
重启生效,需要同时修改这两个参数。
半个月
wait_timeout=1314000
interactive_timeout=1314000
分享到:
相关推荐
autoReconnect=true</property> <property name="user">root</property> <property name="password">password</property> <property name="initialPoolSize">10</property> <property name="minPoolSize">10</...
一.开发环境 IDEA + JDK8 + MySQL5.7 + navicate 二.技术栈 Springboot+Mybatis+layui 三....数据库地址url修改为 spring.datasource.url=jdbc:mysql://localhost:3306/score?...autoReconnect=true&use
<Resource name="zk" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="(此处填你的数据库用户名)" password="(此处填你的数据库密码)" driverClassName=...
autoReconnect=true&useOldAliasMetadataBehavior=true" 中的ofbiz修改为opentaps //opentaps为创建的数据库名字 jdbc-username="ofbiz" 和 jdbc-password="ofbiz" 中的ofbiz修改为mysql上创建了的用户名和密码...
autoReconnect=true&useUnicode=true&characterEncoding=GB2312</value><br/> </parameter><br/> <parameter><br/> <name>username</name><br/> <value>root</value><br/> </parameter><br/> <parameter><br/> ...
autoReconnect=true&characterEncoging=utf8&zeroDateTimeBehavior=convertToNull 3. 完整的配置参数参考intouch2.war!\WEB-INF\config\config.xml 4. 配置文件config.xml中的mail.upflow.com换成实际的...
hibernate自动重新连接数据库proxool的使用及配置
dbcp连接池优化详解,主要是如何应对链接僵死的现象
useUnicode=true&characterEncoding=GB2312&autoReconnect=true jdbc.username.mysql=root jdbc.password.mysql=root 3、 Web容器:tomcat6.x 4、 页面访问路径: 论坛首页: http://localhost:8080/bbs 后台管理...
autoReconnect=true&useUnicode=true&characterEncoding=GB2312</value><br/> </parameter><br/> <parameter><br/> <name>username</name><br/> <value>root</value><br/> </parameter><br/> <parameter><br/> ...
serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true&useSSL=false username: root password: 123456 默认用户名和密码为 root / 123456 默认数据库名为:...
autoReconnect=true&useUnicode=true&characterEncoding=utf-8</value> </property> <property name="username"> <value>empty</value> </property> <property name="password"> <value>empty</value>...
修改mysql 8.0版本使用 server.servlet.context...characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8 db.user=root db.password=123456
OpenAMEE 平台 在本地运行平台 在 settings.xml 中创建一个 Maven 配置文件 ...autoReconnect=true & autoReconnectForPools=true & useCompression=false</ db> < rabbitmq>localhost</ rabbitmq>
有关已编译的发行版,请参见release文件夹用法键入java -Xmx2048 -jar <jarfile> -h以获取: Usage: dbexport [options]Options: -J, --jdbc jdbc-url localhost JDBC url ensure that the correct jdbc drivers ...
<Resource driverClassName=...autoReconnect=true" />
在Docker上使用MySQL docker运行--name some-mysql -h localhost -p 3306:3306 -e MYSQL_ROOT_PASSWORD = sifre -d mysql 示例用户和角色(运行sql命令...autoreconnect=true" password: "sifre" username: "root
autoReconnect=true</value> </parameter> <br> 4. 请将 WebRoot.xml copy到 D:\Tomcat5\conf\Catalina\localhost\下 数据库的配置就在这个文件中 <br>5. 文件mysql-connector-java-5.0.5-bin....
数据库对象 Java 轻量级库,用于在基于 JDBC 的关系数据库中存储和... autoReconnect=true maxReconnects=3 用法 定义一个实体: @DbEntity(name = "user") public class User { ..... } 定义一个属性: @Db
c3p0 重新自动连接 c3p0 重新自动连接 c3p0 重新自动连接 &autoReconnect=true