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
- c3p0异常
- c3p0异常
- C3P0异常处理
- c3p0 PoolBackedDataSource 异常
- C3P0连接池异常处理
- Mysql+C3P0+Hibernate,偶发性异常
- spring c3p0连接数据库异常
- 使用C3P0抛出UnknownHostException异常
- c3p0报空指针异常
- c3p0 com.mysql.jdbc.CommunicationsException异常
- c3p0 com.mysql.jdbc.CommunicationsException异常
- hiberante集成c3p0出现的异常分析
- C3P0连接池连接异常错误解决
- C3P0连接池连接异常错误解决
- c3p0 com.mysql.jdbc.CommunicationsException异常
- c3p0配置文件错误所产生的异常
- C3P0
- c3p0
- 有向图的十字链表存储
- jQuery插件之ajaxFileUpload
- Android 设置 横屏 竖屏
- Java基础重点回顾
- android开发笔记--时间控件只显示年月不显示日期【如有需要可以更为只显示月日不显示年份】
- c3p0异常
- MongoDB笔记3-shell collection对象
- SOAP详解
- Android设置虚线、圆角、渐变
- 3.8
- JAVA 整型和字符串互相转换
- 读好书的心得体会
- 人民日报任仲平:凝聚当代中国的价值公约数
- 第三章第七题(3)