在连接mysql时遇到的问题及解决(SSM)
** END NESTED EXCEPTION ** Last packet sent to the server was 0 ms ago. at com.mysql.jdbc.Connection.createNewIO(Connection.java:2658) at com.mysql.jdbc.Connection.(Connection.java:1509) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266) at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:135) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
解决方法 1
1 直接用sql命令行修改
mysql> set global wait_timeout=1814400; mysql> set global interactive_timeout=1814400; #注:wait_timeout=1814400 = 21小时
查看超时时长
mysql> show global variables like 'wait_timeout';
//该方法不推荐 ,服务重启修改会还原
解决方法2? 修改 my.ini文件( mysql安装目录bin文件夹下 )
打开my.ini文件
//搜索此项 [mysqld] //添加下面两行,重启服务 wait_timeout=31536000 interactive_timeout=31536000
检查 url连接 ip ,端口占用,账号密码 ,如果是localhost 更改为IP ?jdbc:mysql://192.168.10.112:3306/test?useUnicode=true&characterEncoding=utf-8&autoReconnect=true 也可能是服务器宕机了。。。
如对本文有疑问, 点击进行留言回复!!
网友评论