c3p0异常

来源:互联网 发布:龙族js挂机脚本 编辑:程序博客网 时间:2024/05/16 11:55
Caused by: com.mchange.v2.resourcepool.ResourcePoolException: Attempted to use a closed or broken resource pool    at com.mchange.v2.resourcepool.BasicResourcePool.ensureNotBroken(BasicResourcePool.java:1735)    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:573)    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:526)    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:755)    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:682)    ... 88 more四月 20, 2015 3:17:58 下午 org.apache.catalina.core.ApplicationContext log信息: Initializing Spring FrameworkServlet 'springServlet'四月 20, 2015 3:18:38 下午 org.apache.catalina.startup.HostConfig deployDirectory信息: Deploying web application directory ROOT四月 20, 2015 3:18:39 下午 org.apache.coyote.http11.Http11Protocol start信息: Starting Coyote HTTP/1.1 on http-8888四月 20, 2015 3:18:42 下午 org.apache.jk.common.ChannelSocket init信息: JK: ajp13 listening on /0.0.0.0:8009四月 20, 2015 3:18:42 下午 org.apache.jk.server.JkMain start信息: Jk running ID=0 time=0/481  config=null四月 20, 2015 3:18:42 下午 org.apache.catalina.startup.Catalina start信息: Server startup in 142564 ms


spring配置

<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:security="http://www.springframework.org/schema/security"xmlns:context="http://www.springframework.org/schema/context"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans.xsd        http://www.springframework.org/schema/context        http://www.springframework.org/schema/context/spring-context.xsd        http://www.springframework.org/schema/tx        http://www.springframework.org/schema/tx/spring-tx.xsd        http://www.springframework.org/schema/aop         http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"><!-- bean的生命周期回调函数 <bean class="com.test.control.MyBeanPostProcessor"/> --><import resource="/beans.xml" /><context:component-scan base-package="com.h3c.itac" /><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close"><property name="driverClass"><value>com.mysql.jdbc.Driver</value></property><property name="jdbcUrl"><value>jdbc:mysql://localhost:3306/itac</value></property><property name="user"><value>root</value></property><property name="password"><value>root</value></property><!--连接池中保留的最小连接数。 --><property name="minPoolSize" value="10" /><!--连接池中保留的最大连接数。Default: 15 --><property name="maxPoolSize" value="100" /><!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 --><property name="maxIdleTime" value="1800" /><!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 --><property name="acquireIncrement" value="5" /><property name="maxStatements" value="1000" /><property name="initialPoolSize" value="10" /><!--每60秒检查所有连接池中的空闲连接。Default: 0 --><property name="idleConnectionTestPeriod" value="60" /><!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 --><property name="acquireRetryAttempts" value="30" /><property name="breakAfterAcquireFailure" value="true" /><property name="testConnectionOnCheckout" value="false" /></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="packagesToScan" value="com.h3c.itac" /><property name="hibernateProperties"><value>hibernate.dialect=org.hibernate.dialect.MySQL5Dialecthibernate.hbm2ddl.auto=updatehibernate.connection.autocommit=truehibernate.show_sql=falsehibernate.format_sql=falsehibernate.cache.use_second_level_cache=truehibernate.cache.use_query_cache=falsehibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext</value></property></bean><bean id="txManager"class="org.springframework.orm.hibernate4.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory"></property><property name="nestedTransactionAllowed" value="true" /></bean><bean class="com.h3c.itac.HibernateBaseDao"></bean><tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"mode="proxy" /></beans>

使用的jar

antlr-2.7.7.jaraopalliance.jaraspectj-1.8.3.jaraspectjweaver-1.6.9.jarc3p0-0.9.2.1.jarcommons-logging-1.0.4.jardom4j-1.6.1.jargson-2.2.4.jarhibernate-c3p0-4.3.7.Final.jarhibernate-commons-annotations-4.0.5.Final.jarhibernate-core-4.3.7.Final.jarhibernate-jpa-2.1-api-1.0.0.Final.jarjavassist-3.18.1-GA.jarjboss-logging-3.1.3.GA.jarjboss-logging-annotations-1.2.0.Beta1.jarjboss-transaction-api_1.2_spec-1.0.0.Final.jarlog4j-1.2.17.jarmchange-commons-java-0.2.3.4.jarmysql-connector-java-5.1.18-bin.jarslf4j-api-1.6.1.jarspring-aop-4.1.2.RELEASE.jarspring-aspects-4.1.2.RELEASE.jarspring-beans-4.1.2.RELEASE.jarspring-context-4.1.2.RELEASE.jarspring-context-support-4.1.2.RELEASE.jarspring-core-4.1.2.RELEASE.jarspring-expression-4.1.2.RELEASE.jarspring-jdbc-4.1.2.RELEASE.jarspring-orm-4.1.2.RELEASE.jarspring-security-config-3.2.5.RELEASE.jarspring-security-core-3.2.5.RELEASE-javadoc.jarspring-security-core-3.2.5.RELEASE.jarspring-security-web-3.2.5.RELEASE.jarspring-tx-4.1.2.RELEASE.jarspring-web-4.1.2.RELEASE.jarspring-webmvc-4.1.2.RELEASE.jarsqlite-jdbc-3.8.6.jarstandard.jar


其实问题很清楚了, Attempted to use a closed or broken resource pool,刚开始看到这句话感觉是数据源问题,然后去检查数据源的相关c3p0的相关jar和配置,网上有种说法是缺少配置:

<property name="acquireRetryAttempts" value="30" /><property name="breakAfterAcquireFailure" value="true" /><property name="testConnectionOnCheckout" value="false" />
但是本xml中已经进行了这个配置,所以问题不是在这里,但是比较奇怪的是:cmd命令行可以顺利的连接上mysql

当时还不是特别确定是不是c3p0的问题,所以,就想到用普通的jdbc程序连接一下数据库试试。


首先可以确定的是,我用root用户名和root密码在cmd中是可以连接上mysql的,所以就比较奇怪了,为什么cmd可以,编程却不可以

,最终原因是本地mysql的问题,更换了sqlite数据库,则可以正常运行




0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 蹲久了膝盖疼怎么办 怀孕了外阴痒怎么办啊 我老婆出轨了我该怎么办 老婆有外遇我该怎么办 纸卡在打印机里怎么办 脸上的颧骨太高怎么办? 脸磕了一下淤血怎么办 腿磕到了有淤血怎么办 屁股摔了很疼怎么办 摔了脚踝肿了怎么办 扭了脚肿起来了怎么办 发际线低额头窄怎么办 档案写错了涂改怎么办 当时档案写错了怎么办 档案内容写错了怎么办 高中档案写错了怎么办 上大学档案丢了怎么办 u盘总提示格式化怎么办 黑莓手机id锁了怎么办 美图手机进水了怎么办 球兰叶子发黄软怎么办 蟹爪莲叶子发红怎么办 保险箱没电了打不开怎么办 宁波臭冬瓜酸的怎么办 甜酒酿做了酸了怎么办 孕妇喝了醪糟汤怎么办 鱼侧翻但又没死怎么办 原汁机盖子卡死怎么办 惠人原汁机坏了怎么办 泡芙鸡蛋加多了怎么办 淡奶油打过了怎么办 淡奶油打发过了怎么办 雷神锤子被捏碎怎么办 私处毛很多很黑怎么办 脸上长黑色的毛怎么办 十字军之王2毁容怎么办 多囊卵巢综合症想怀孕怎么办 12306账户名忘了怎么办 丧尸病毒爆发了怎么办 看了鬼故事害怕怎么办 微信验证码忘了怎么办