连接mysq数据库出错

问题描述

Poolthreadstacktraces:Thread[C3P0PooledConnectionPoolManager[identityToken->1brasyf95l92zyz1d2slpg|2bc50502]-HelperThread-#1,5,main]java.net.DualStackPlainSocketImpl.connect0(NativeMethod)java.net.DualStackPlainSocketImpl.socketConnect(UnknownSource)java.net.AbstractPlainSocketImpl.doConnect(UnknownSource)java.net.AbstractPlainSocketImpl.connectToAddress(UnknownSource)java.net.AbstractPlainSocketImpl.connect(UnknownSource)java.net.PlainSocketImpl.connect(UnknownSource)java.net.SocksSocketImpl.connect(UnknownSource)java.net.Socket.connect(UnknownSource)java.net.Socket.connect(UnknownSource)java.net.Socket.<init>(UnknownSource)java.net.Socket.<init>(UnknownSource)com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)sun.reflect.NativeConstructorAccessorImpl.newInstance(UnknownSource)sun.reflect.DelegatingConstructorAccessorImpl.newInstance(UnknownSource)java.lang.reflect.Constructor.newInstance(UnknownSource)com.mysql.jdbc.Util.handleNewInstance(Util.java:411)com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)Thread[C3P0PooledConnectionPoolManager[identityToken->1brasyf95l92zyz1d2slpg|2bc50502]-HelperThread-#0,5,main]java.net.DualStackPlainSocketImpl.connect0(NativeMethod)java.net.DualStackPlainSocketImpl.socketConnect(UnknownSource)java.net.AbstractPlainSocketImpl.doConnect(UnknownSource)java.net.AbstractPlainSocketImpl.connectToAddress(UnknownSource)java.net.AbstractPlainSocketImpl.connect(UnknownSource)java.net.PlainSocketImpl.connect(UnknownSource)java.net.SocksSocketImpl.connect(UnknownSource)java.net.Socket.connect(UnknownSource)java.net.Socket.connect(UnknownSource)java.net.Socket.<init>(UnknownSource)java.net.Socket.<init>(UnknownSource)com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)sun.reflect.NativeConstructorAccessorImpl.newInstance(UnknownSource)sun.reflect.DelegatingConstructorAccessorImpl.newInstance(UnknownSource)java.lang.reflect.Constructor.newInstance(UnknownSource)com.mysql.jdbc.Util.handleNewInstance(Util.java:411)com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)Thread[C3P0PooledConnectionPoolManager[identityToken->1brasyf95l92zyz1d2slpg|2bc50502]-HelperThread-#2,5,main]java.net.DualStackPlainSocketImpl.connect0(NativeMethod)java.net.DualStackPlainSocketImpl.socketConnect(UnknownSource)java.net.AbstractPlainSocketImpl.doConnect(UnknownSource)java.net.AbstractPlainSocketImpl.connectToAddress(UnknownSource)java.net.AbstractPlainSocketImpl.connect(UnknownSource)java.net.PlainSocketImpl.connect(UnknownSource)java.net.SocksSocketImpl.connect(UnknownSource)java.net.Socket.connect(UnknownSource)java.net.Socket.connect(UnknownSource)java.net.Socket.<init>(UnknownSource)java.net.Socket.<init>(UnknownSource)com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)sun.reflect.NativeConstructorAccessorImpl.newInstance(UnknownSource)sun.reflect.DelegatingConstructorAccessorImpl.newInstance(UnknownSource)java.lang.reflect.Constructor.newInstance(UnknownSource)com.mysql.jdbc.Util.handleNewInstance(Util.java:411)com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)2014-10-2621:15:14[com.mchange.v2.async.ThreadPoolAsynchronousRunner]-[DEBUG]Apparentlysomethreadshavebeenreplaced.Replacementthreadprocessingenabled.2014-10-2621:15:15[com.mchange.v2.resourcepool.BasicResourcePool]-[DEBUG]Anexceptionoccurredwhileacquiringapoolableresource.Willretry.com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:CommunicationslinkfailureThelastpacketsentsuccessfullytotheserverwas0millisecondsago.Thedriverhasnotreceivedanypacketsfromtheserver.

解决方案

解决方案二:
你的代码呢,贴出来看看
解决方案三:
MySQL服务器默认的“wait_timeout”是28800秒即8小时,意味着如果一个连接的空闲时间超过8个小时,MySQL将自动断开该连接,而连接池却认为该连接还是有效的(因为并未校验连接的有效性),当应用申请使用该连接时,就会导致上面的报错。解决办法有两个:一是修改my.cnf:[mysqld]wait_timeout=31536000interactive_timeout=31536000
解决方案四:
二是在连接URL上添加参数:&autoReconnect=true&failOverReadOnly=false
解决方案五:
继续深入研究一下吧。
解决方案六:
jar包加了吗?
解决方案七:
如果是8小时问题,这么配置:<beanid="dataSource"class="org.apache.commons.dbcp.BasicDataSource"><propertyname="driverClassName"value="com.mysql.jdbc.Driver"></property><propertyname="url"value="jdbc:mysql://...."></property><propertyname="username"value="...."></property><propertyname="password"value="...."></property><propertyname="validationQuery"value="SELECT1"></property><propertyname="testWhileIdle"value="true"></property><propertyname="timeBetweenEvictionRunsMillis"value="3600000"></property><propertyname="minEvictableIdleTimeMillis"value="18000000"></property><propertyname="testOnBorrow"value="true"></property></bean>

时间: 2024-11-10 09:39:09

连接mysq数据库出错的相关文章

qt 连接Access数据库出错

问题描述 qt 连接Access数据库出错 qt 连接Access数据库出错[Microsoft][ODBC驱动程序管理器]未发现数据源名称并且未指定默认驱动程序 QODBC3:Unable to connect 我已经在控制面板里配置了数据源,选择的是Microsoft Access Driver (*.mdb, *.accdb)驱动器,开发环境Qt5, Access2013, win10 db = QSqlDatabase::addDatabase("QODBC", "t

python连接mysql数据库出错,已经试了网上的几种方法,,求助

问题描述 python连接mysql数据库出错,已经试了网上的几种方法,,求助 http://blog.csdn.net/lishan9133/article/details/7024989 之前是按照上面的教程安装了mysqldb模块,可是在实际操作过程中,找不到对应行的代码,所以并没有按照上面的改. 打开数据库连接 db = MySQLdb.connect( host='192.188.80.41', port=3306, user='root', passwd='123456', db='

Postgres连接本地数据库出错-&amp;amp;quot;连线被拒,请检查主机名称和埠号,并确定 postmaster 可以接受 TCP/IP 连线&amp;amp;quot;

问题描述 别的电脑远程连接我的数据库,没有问题,为什么我自己却不能连接自己呢?网上查了下,说是要改pg_hba.conf配置文件,这里我已经改了,但还没用,而且改这个地方是为了支持远程连接的,我这是本地连接.以下是报错的详细信息:org.postgresql.util.PSQLException:连线被拒,请检查主机名称和埠号,并确定postmaster可以接受TCP/IP连线.atorg.postgresql.core.v3.ConnectionFactoryImpl.openConnecti

java频繁连接sql数据库,出错,求高手帮忙,系统快上线了

问题描述 严重:nullINFO|jvm1|2011/03/2720:36:43|[dscp:/subroutine/lol_DB_Utility/1.pnutline:291]:INFO|jvm1|2011/03/2720:36:43|executeInterfaceQuery(sun.jdbc.odbc.JdbcOdbcConnection@b67cf0,"select*fromequipmentStateInfowhereisEfficiency='0'andEquipmentIDin('

javabean 连接MySQL数据库出错

问题描述 javabean代码:packagecom.am;importjava.sql.*;publicclassOpenDB{StringuserName="root";StringuserPassword="jingxian";Stringdatabase="am";Stringhost="localhost";//privateStringdriverName="org.gjt.mm.mysql.Driver

c++-C++连接mysql数据库时,用getString()方法总是出错

问题描述 C++连接mysql数据库时,用getString()方法总是出错 http://www.cnblogs.com/joeblackzqq/p/4332945.html 我按照上面这个链接的教程,用了第二种Connector C++的方法,配置好boost的路径和mysql的路径后,就修改了一下范例的代码: #include <iostream> #include <map> #include <string> #include <memory> #

JDBC连接Oracle数据库常见问题及解决方法

oracle|解决|数据|数据库|问题 Jbuilder正确连接 oracle 9i需要注意的几个问题 oracle8以上的应该都使用classes12.jar文件作为jdbc驱动: 正确设置windows的classpath和jbuilder中的enterprise setup .configure libraries,将casses12.jar路径正确添加到上述需要设置的地方: 进入database pilot,在database pilot中,file---new 在driver列表中如果

轻松应对JSP连接MySQL数据库问题

当您面临JSP连接MySQL数据库问题,你首先需要在MySQL数据库里创建一username表,表里面创建两个字符型的字段,字段名分别为:uid,pwd,然后插入几条测试数据. 以下用两种方式来实现JSP连接MySql数据库 第一种方式,用JSP实现: <%@ page contentType="text/html; charset=gb2312" language="java"  import="java.sql.*"%><m

实现JSP连接MySql数据库的两种方式

js|mysql|数据|数据库 当您面临JSP连接MySQL数据库问题,你首先需要在MySQL数据库里创建一username表,表里面创建两个字符型的字段,字段名分别为:uid,pwd,然后插入几条测试数据. 以下用两种方式来实现JSP连接MySql数据库 第一种方式,用JSP实现: <%@ page contentType="text/html; charset=gb2312" language="java"  import="java.sql.*