spring数据源配置问题

警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@18becb95 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).
九月 23, 2016 4:58:11 下午 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask run
警告: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@56b2912f -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).
Exception in thread "main" java.sql.SQLException: Connections could not be acquired from the underlying database!
at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:104)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:264)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
at com.mchange.v2.c3p0.ComboPooledDataSource.getConnection(ComboPooledDataSource.java:521)
at com.yang.spring.properties.Main.main(Main.java:18)
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.awaitAcquire(BasicResourcePool.java:972)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:208)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:260)
... 3 more

beans-properties.xml





导入了c3p0-0.9.0.2.jar mysql-connector-java-5.1.39-bin.jar
mysql-5.7.14 64位。 cmd下可以用root ,123 登录mysql。

1个回答

 <!-- 数据库连接配置 -->
    <bean id="dataSource"
        class="com.mchange.v2.c3p0.ComboPooledDataSource"
        destroy-method="close">
        <property name="driverClass" value="${c3p0.driverClass}"></property>
        <property name="jdbcUrl" value="${c3p0.url}"></property>
        <property name="user" value="${c3p0.user}"></property>
        <property name="password" value="${c3p0.password}"></property>
        <property name="acquireIncrement" value="${c3p0.acquireIncrement}"></property>
        <property name="initialPoolSize" value="${c3p0.initialPoolSize}"></property>
        <property name="maxIdleTime" value="${c3p0.maxIdleTime}"></property>
        <property name="maxPoolSize" value="${c3p0.maxPoolSize}"></property>
        <property name="minPoolSize" value="${c3p0.minPoolSize}"></property>
        <property name="acquireRetryDelay" value="1000"></property>
        <property name="acquireRetryAttempts" value="60"></property>
        <property name="breakAfterAcquireFailure" value="false"></property>
    </bean>
 ######C3P0 MySQL config #######  
c3p0.url=jdbc:oracle:thin:@localhost:1521:XE
c3p0.user=shichen
c3p0.password=123456
c3p0.driverClass=oracle.jdbc.OracleDriver
c3p0.acquireIncrement = 1
c3p0.maxIdleTime = 60
c3p0.maxPoolSize = 200
c3p0.minPoolSize = 50
c3p0.initialPoolSize = 100
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐