Home > Back-end >  Remember a c3p0 connection pool to connect the mysql database error
Remember a c3p0 connection pool to connect the mysql database error

Time:03-15

Mysql version 8.0.22

Paste the code first:




In the DataSource for database connection times wrong:
Java. SQL. SQLException: Connections could not be acquired from the physicist 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 com. Test. SqlSession. SimpleExcuter. Query (SimpleExcuter. Java: 23)
At com. Test. SqlSession. DefaultSqlSession. SelectList (DefaultSqlSession. Java: 19)
At com. Test. SqlSession. DefaultSqlSession. SelectOne (25) DefaultSqlSession. Java:
At com. Test. Pojo. TestMain. Test (TestMain. Java: 77)
The at Java. The base/JDK. Internal. Reflect. NativeMethodAccessorImpl. Invoke0 (Native Method)
The at Java. The base/JDK. Internal. Reflect. NativeMethodAccessorImpl. Invoke (NativeMethodAccessorImpl. Java: 62)
The at Java. The base/JDK. Internal. Reflect. DelegatingMethodAccessorImpl. Invoke (43) DelegatingMethodAccessorImpl. Java:
The at Java. The base/Java. Lang. Reflect. Method. Invoke (566) Method. The Java:
The at org. Junit. Runners. Model. FrameworkMethod $1. RunReflectiveCall (FrameworkMethod. Java: 50)
The at org. Junit. Internal. Runners. Model. ReflectiveCallable. Run (ReflectiveCallable. Java: 12)
The at org. Junit. Runners. Model. FrameworkMethod. InvokeExplosively (FrameworkMethod. Java: 47)
The at org. Junit. Internal. Runners. Statements. InvokeMethod. Evaluate (InvokeMethod. Java: 17)
The at org. Junit. Runners. ParentRunner. RunLeaf (ParentRunner. Java: 325)
The at org. Junit. Runners. BlockJUnit4ClassRunner. RunChild (BlockJUnit4ClassRunner. Java: 78)
The at org. Junit. Runners. BlockJUnit4ClassRunner. RunChild (BlockJUnit4ClassRunner. Java: 57)
The at org. Junit. Runners. ParentRunner $3. The run (ParentRunner. Java: 290)
The at org. Junit. Runners. ParentRunner $1. The schedule (ParentRunner. Java: 71)
The at org. Junit. Runners. ParentRunner. RunChildren (ParentRunner. Java: 288)
The at org. Junit. Runners. ParentRunner. Access the $000 (ParentRunner. Java: 58)
At org. Junit. Runners. ParentRunner $2. The evaluate (ParentRunner. Java: 268)
The at org. Junit. Runners. ParentRunner. Run (ParentRunner. Java: 363)
The at org. Junit. Runner. JUnitCore. Run (JUnitCore. Java: 137)
At com. Intellij. Takeup. JUnit4IdeaTestRunner. StartRunnerWithArgs (JUnit4IdeaTestRunner. Java: 68)
At com. Intellij. Rt. Junit. IdeaTestRunner $Repeater. StartRunnerWithArgs (IdeaTestRunner. Java: 33)
At com. Intellij. Rt. Junit. JUnitStarter. PrepareStreamsAndStart (JUnitStarter. Java: 230)
At com. Intellij. Rt. Junit. JUnitStarter. Main (58) JUnitStarter. Java:
Under 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)
. 27 more


Reason:
MySQL 8.0 the following version - JDBC driver name and database URL

The static final String JDBC_DRIVER=". Com. Mysql. JDBC Driver ".
The static final String DB_URL="JDBC: mysql://localhost: 3306/test".

MySQL 8.0 above - JDBC driver name and database URL

The static final String JDBC_DRIVER=". Com. Mysql. Cj. JDBC Driver ".
The static final String DB_URL="JDBC: mysql://localhost: 3306/test? UseSSL=false& ServerTimezone=UTC ";

Solution:
JdbcUrl plus serverTimezone parameters in the configuration file is good

  • Related