求助:使用C3P0出错!? 400 报错
配置文件的所有内容:
c3p0.jdbcUrl=jdbc:oracle:thin:@XXX.XXX.XXX.XXX:1521:ora10g c3p0.driverClass=oracle.jdbc.driver.OracleDriver c3p0.user=XXX c3p0.password=XXX c3p0.minPoolSize=3 c3p0.maxPoolSize=20 com.mchange.v2.log.MLog=com.mchange.v2.log.log4j.Log4jMLog com.mchange.v2.log.NameTransformer=com.mchange.v2.log.PackageNames com.mchange.v2.log.FallbackMLog.DEFAULT_CUTOFF_LEVEL=ALL
获取连接代码:
ComboPooledDataSource cpds = new ComboPooledDataSource(); conn = cpds.getConnection();出错信息:
log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog). log4j:WARN Please initialize the log4j system properly. java.sql.SQLException: Connections could not be acquired from the underlying database! at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at c3p0.testc3p0.main(testc3p0.java:21) Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319) at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557) at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525) ... 2 more真心求助!谢谢大家!
从错误信息来看跟配置和代码无关了,看看数据库是否可连接
######
C3P0启动?!我是直接在程序里包含c3p0的一个jar包,然后就写配置文件的内容,再写程序代码,直接点击运行控制台就打印上面的信息了,没看到控制台输出配置信息啊?!难道是我用c3p0的方式不对?
什么信息,我也遇到这个问题。
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.testConnectionOnCheckout">true</property>
很有可能是数据库归档日志已满,处理下日志。
######c3p0.jdbcUrl
这里是不是少了个连字符-
c3p0.jdbc-Url
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。