我尝试从运行在Tomcat中的Spring应用程序连接到本地MySQL数据库,我知道它正在运行,但C3P0无法获取连接。
context.xml中
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/cas">
<Resource name="jdbc/dataSource"
user="cas_app"
password="cas_app"
auth="Container"
description="cas"
initialPoolSize="6"
acquireIncrement="6"
minPoolSize="6"
maxPoolSize="18"
maxConnectionAge="25000"
maxIdleTime="120"
maxIdleTimeExcessConnections="300"
idleConnectionTestPeriod="30"
testConnectionOnCheckin="true"
testConnectionOnCheckout="false"
preferredTestQuery="SELECT 1"
maxStatements="0"
maxStatementsPerConnection="0"
acquireRetryAttempts="5"
acquireRetryDelay="2000"
breakAfterAcquireFailure="true"
driverClass="com.mysql.jdbc.Driver"
factory="org.apache.naming.factory.BeanFactory"
jdbcUrl="jdbc:mysql://localhost/cas_ticket_registry?useUnicode=yes&characterEncoding=UTF-8"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
/>
</Context>
当我运行Tomcat时,我收到以下错误
15-Jan-2016 06:28:30.314 INFO [localhost-startStop-1] org.hibernate.Version.logVersion HHH000412: Hibernate Core {4.3.10.Final}
15-Jan-2016 06:28:30.317 INFO [localhost-startStop-1] org.hibernate.cfg.Environment.<clinit> HHH000206: hibernate.properties not found
15-Jan-2016 06:28:30.319 INFO [localhost-startStop-1] org.hibernate.cfg.Environment.buildBytecodeProvider HHH000021: Bytecode provider name : javassist
15-Jan-2016 06:28:30.592 INFO [localhost-startStop-1] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
06:28:40.748 [C3P0PooledConnectionPoolManager[identityToken->1hge0wj9ej5nr1f11ag6qu|76957520]-HelperThread-#2] ERROR com.mchange.v2.resourcepool.BasicResourcePool - A RESOURCE POOL IS PERMANENTLY BROKEN! [com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@bd387a8] (because a series of 5 acquisition attempts failed.)
06:28:40.748 [C3P0PooledConnectionPoolManager[identityToken->1hge0wj9ej5nr1f11ag6qu|76957520]-HelperThread-#0] ERROR com.mchange.v2.resourcepool.BasicResourcePool - A RESOURCE POOL IS PERMANENTLY BROKEN! [com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@6e3f8384] (because a series of 5 acquisition attempts failed.)
06:28:40.748 [C3P0PooledConnectionPoolManager[identityToken->1hge0wj9ej5nr1f11ag6qu|76957520]-HelperThread-#1] ERROR com.mchange.v2.resourcepool.BasicResourcePool - A RESOURCE POOL IS PERMANENTLY BROKEN! [com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@1916bfd5] (because a series of 5 acquisition attempts failed.)
06:28:40.753 [C3P0PooledConnectionPoolManager[identityToken->1hge0wj9ej5nr1f11ag6qu|76957520]-HelperThread-#0] ERROR com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@41ebd171 -- Unexpectedly broken!!!
com.mchange.v2.resourcepool.ResourcePoolException: Unexpected Break Stack Trace!
at com.mchange.v2.resourcepool.BasicResourcePool.unexpectedBreak(BasicResourcePool.java:974)
at com.mchange.v2.resourcepool.BasicResourcePool.access$1000(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1927)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
06:28:40.754 [C3P0PooledConnectionPoolManager[identityToken->1hge0wj9ej5nr1f11ag6qu|76957520]-HelperThread-#1] ERROR com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool@41ebd171 -- Unexpectedly broken!!!
com.mchange.v2.resourcepool.ResourcePoolException: Unexpected Break Stack Trace!
at com.mchange.v2.resourcepool.BasicResourcePool.unexpectedBreak(BasicResourcePool.java:974)
at com.mchange.v2.resourcepool.BasicResourcePool.access$1000(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1927)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
我还尝试将端口添加到网址,以便它是jdbcUrl="jdbc:mysql://localhost:3306/cas_ticket_registry?useUnicode=yes&characterEncoding=UTF-8"
,但这没有什么区别。
但是,当我可以通过命令行连接时。
terskine@WOZNIAK:../~$ mysql -u cas_app -p cas_ticket_registry
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.17 Homebrew
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select 1
-> ;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
mysql>
我真的很感激你能给予的任何帮助。感谢。