jdbc报错啦,这到底是什么问题呢.搞了好久啊!

Skqing 发布于 2013/12/16 17:18
阅读 17K+
收藏 0
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.GeneratedConstructorAccessor17.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_45]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[na:1.7.0_45]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406) ~[mysql-connector-java-5.1.9.jar:na]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074) ~[mysql-connector-java-5.1.9.jar:na]
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:343) ~[mysql-connector-java-5.1.9.jar:na]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2132) ~[mysql-connector-java-5.1.9.jar:na]
... 169 common frames omitted
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method) ~[na:1.7.0_45]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79) ~[na:1.7.0_45]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) ~[na:1.7.0_45]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) ~[na:1.7.0_45]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) ~[na:1.7.0_45]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.7.0_45]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.7.0_45]
at java.net.Socket.connect(Socket.java:579) ~[na:1.7.0_45]
at java.net.Socket.connect(Socket.java:528) ~[na:1.7.0_45]
at java.net.Socket.<init>(Socket.java:425) ~[na:1.7.0_45]
at java.net.Socket.<init>(Socket.java:241) ~[na:1.7.0_45]
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253) ~[mysql-connector-java-5.1.9.jar:na]
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:292) ~[mysql-connector-java-5.1.9.jar:na]
... 170 common frames omitted
加载中
0
Skqing
Skqing
我不用c3p0了直接换成

Druid

问题就没了.

0
whaon
whaon
连接错误,检查url地址,用户名,密码
0
南湖船老大
南湖船老大

Caused by: java.net.ConnectException: Connection refused: connect

估计是代码没写好,泄露了

孤单时会想你
孤单时会想你
也可能是mysql服务没启动 或者数据库没装好
0
Skqing
Skqing
项目基本没什么代码, 只是搭建一个环境而已!  spring+springmvc + mybatis
0
Ryan-瑞恩
Ryan-瑞恩

单独写一个数据库连接看看。。。。是不是数据库的问题。

0
Skqing
Skqing
嗯, 我试试再说!
0
huan
huan
很常见的问题,路由切断了长时间不活跃的tcp链接,但是连接池还是拿出来直接用,导致错误产生,只要配置连接池使用连接前测试,以及抛弃不活跃连接即可。
0
Skqing
Skqing

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driverClass}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="minPoolSize" value="${jdbc.miniPoolSize}" />
<property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>  
<property name="initialPoolSize" value="${jdbc.initialPoolSize}"/>
<property name="maxIdleTime" value="${jdbc.maxIdleTime}"/>
<property name="acquireIncrement" value="${jdbc.acquireIncrement}"/>

<property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}"/>
<property name="acquireRetryDelay" value="${jdbc.acquireRetryDelay}"/>
<property name="testConnectionOnCheckin" value="${jdbc.testConnectionOnCheckin}"/>
<property name="automaticTestTable" value="${jdbc.automaticTestTable}"/>
<property name="preferredTestQuery" value="${jdbc.validationQuery}" />
<property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}"/>
<property name="checkoutTimeout" value="${jdbc.checkoutTimeout}"/>
    </bean>

jdbc.miniPoolSize=3

jdbc.maxPoolSize=30
jdbc.initialPoolSize=5
jdbc.maxIdleTime=25000
jdbc.acquireIncrement=1
jdbc.acquireRetryAttempts=30
jdbc.acquireRetryDelay=1000
jdbc.testConnectionOnCheckin=true
jdbc.automaticTestTable=c3p0TestTable
jdbc.validationQuery='SELECT 1'
jdbc.idleConnectionTestPeriod=18000
jdbc.checkoutTimeout=3000
0
huan
huan
应该是 testConnectionOnCheckout
0
Skqing
Skqing
[main] ERROR org.apache.ibatis.executor.BaseExecutor -
Could not get a databaseId from dataSource
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
返回顶部
顶部