Note some of my own low-level mistakes, if it helps, it’s an honor
Recently, I followed the school to learn dynamic javaweb, and the following error occurred when I used c3p0. It probably means that the connection timed out. I searched a lot, and they all said that it was a problem with the c3p0 configuration file. Finally, I found that it was related to the mysql version, which was reduced from 8 to 5.5, and the database was successfully found. content
The content of the error is as follows
June 26, 2022 2:09:15 PM com.mchange.v2.log.MLog <clinit> Info: MLog clients using java 1.4 + standard logging. June 26, 2022 2:09:16 pm com.mchange.v2.c3p0.C3P0Registry banner INFO: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10] June 26, 2022 2:09:16 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager Information: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout - > 30000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge0ytap180hwervupaz4|2dda6444, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver , factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge0ytap180hwervupaz4|2dda6444, idleConnectionTestPeriod -> 0, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://localhost:3306/myshop?useSSL=true & amp;characterEncoding =UTF-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 30, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPool Size -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin - > false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ] June 26, 2022 2:09:36 PM com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector run Warning: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@8988e90 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! June 26, 2022 2:09:36 PM com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector run Warning: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@8988e90 -- APPARENT DEADLOCK!!! Complete Status: Managed Threads: 3 Active Threads: 3 Active Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@47626bc8 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@bc281ba (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@766f29c8 (com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2) Pending Tasks: com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@73259d00 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@274d9487 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@389d1e85 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@37334137 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@6821174c com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@23034f63 com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@733a14b0 Pool thread stack traces: Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] java.lang.Thread.sleep(Native Method) com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1805) com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547) java.sql.SQLException: An attempt by a client to checkout a Connection has timed out. null at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106) at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:65) at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:527) at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128) at org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:156) at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:285) at com.zpr.dao.impl.UserDaoImpl.selectUserByUname(UserDaoImpl.java:24) at com.zpr.test.UserDaoTest.main(UserDaoTest.java:12) Caused by: com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@67f89fa3 -- timeout at awaitAvailable() at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1317) 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) ... 5 more