C3P0 连接池问题

chengxu2011 2014-12-11 10:54:48
org.springframework.dao.RecoverableDataAccessException:
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 5,246,198 milliseconds ago. The last packet sent successfully to the server was 926,646 milliseconds ago.
### The error may involve com.netposa.dao.SkjjGcjlDao.saveSjkkGcjL-Inline
### The error occurred while setting parameters


项目运行过程中发现数据库报这个错误 然后用的连接池是C3P0的 配置如下:
<bean id="opaqDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!-- 设置JDBC驱动名称 -->
<property name="driverClass" value="com.mysql.jdbc.Driver" />
<!-- 设置JDBC连接URL -->
<property name="jdbcUrl" value="jdbc:mysql://xxx.xx.xx.xx:3306/datatrans?characterEncoding=UTF8" />
<!-- 设置数据库用户名 -->
<property name="user" value="xx" />
<!-- 设置数据库密码 -->
<property name="password" value="xx" />
<!-- 设置连接池最大值 -->
<property name="maxPoolSize" value="50" />
<!-- 设置连接池最小空闲值 -->
<property name="minPoolSize" value="5" />
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize" value="6" />
<!--每60秒检查所有连接池中的空闲连接。Default: 0 -->
<property name="idleConnectionTestPeriod" value="18000" />
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime" value="25000" />
<!-- 当连接池连接耗尽时,客户端getConnection(),所等待的时间 -->
<property name="checkoutTimeout" value="6000" />
<!-- 当连接池耗尽时候,一次获得连接数 -->
<property name="acquireIncrement" value="5" />
<!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->
<property name="acquireRetryAttempts" value="10" />
<!-- 获取connnection时测试是否有效 -->
<property name="testConnectionOnCheckin" value="true" />
<property name="acquireRetryDelay" value="1000" />
<!--可以被缓存的PreparedStatement最大数目。设置适量可大大提高Hibernate性能-->
<property name="maxStatements" value="1000" />
</bean>


为什么会报上面的错误 是这个配置文件哪里有问题吗???求大神指点 这个配置文件怎么修改
...全文
262 4 打赏 收藏 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
chengxu2011 2014-12-12
  • 打赏
  • 举报
回复
这是报错的详细信息:
2014-12-12 01:16:28.136:[ERROR]:com.netposa.service.impl.SkjjGcjsServiceImpl:95:batch to insert fail... and begin to insert one by one
org.springframework.dao.RecoverableDataAccessException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 6,565,386 milliseconds ago.  The last packet sent successfully to the server was 926,646 milliseconds ago.
### The error may involve com.netposa.dao.SkjjGcjlDao.saveSjkkGcjL-Inline
### The error occurred while setting parameters
### SQL: insert into skjj_gcjl   (kkbh,jlbh,hphm,hpzl,jgsj,xszt,clsd,cdfx,cwkc,hpys,cllx,xzqh,sbbh,cdbh,csys,clpp,tplx,tztp,qjtp,rksj,yzsj,sjcz,ylzd1,ylzd2,ylzd3,ylzd4,ylzd5)   values          (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)    ,     (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)    ,     (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)    ,     (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)    ,     (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)    ,     (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)    ,     (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 6,565,386 milliseconds ago.  The last packet sent successfully to the server was 926,646 milliseconds ago.
; SQL []; Communications link failure

The last packet successfully received from the server was 6,565,386 milliseconds ago.  The last packet sent successfully to the server was 926,646 milliseconds ago.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 6,565,386 milliseconds ago.  The last packet sent successfully to the server was 926,646 milliseconds ago.
	at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:99)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
	at com.sun.proxy.$Proxy12.insert(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:46)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
	at com.sun.proxy.$Proxy22.saveSjkkGcjL(Unknown Source)
	at com.netposa.service.impl.SkjjGcjsServiceImpl.save(SkjjGcjsServiceImpl.java:92)
	at com.netposa.facade.impl.SkjjGcjlFacadeImpl.doSkjjService(SkjjGcjlFacadeImpl.java:67)
	at com.netposa.task.TimmerTask.execute(TimmerTask.java:82)
	at sun.reflect.GeneratedMethodAccessor112.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
	at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:318)
	at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:111)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 6,565,386 milliseconds ago.  The last packet sent successfully to the server was 926,646 milliseconds ago.
	at sun.reflect.GeneratedConstructorAccessor173.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3052)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2938)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3481)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2643)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2077)
	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1356)
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
	at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:55)
	at com.sun.proxy.$Proxy35.execute(Unknown Source)
	at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
	at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
	at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
	at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
	at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137)
	at sun.reflect.GeneratedMethodAccessor99.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
	... 16 more
Caused by: java.net.SocketException: Connection timed out
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:152)
	at java.net.SocketInputStream.read(SocketInputStream.java:122)
	at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)
	at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)
	at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2494)
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2949)
	... 40 more
2014-12-12 01:16:28.152:[ERROR]:com.netposa.service.impl.SkjjGcjsServiceImpl:102:Db error....
org.springframework.dao.RecoverableDataAccessException: 
### Error updating database.  Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
求大声看下 是不是C3P0的配置哪里有问题啊
LOVE-漂泊 2014-12-12
  • 打赏
  • 举报
回复
jdbc连接 加上 autoReconnectForPools=true
qzw1210 2014-12-11
  • 打赏
  • 举报
回复
检查运行时的参数和数据库中字段类型是否对应。这里报的是更新数据时报错。
乔不思 2014-12-11
  • 打赏
  • 举报
回复
### The error occurred while setting parameters

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧