current position:Home>After spring imports the database and c3p0 dependency package in idea, it will prompt the database for abnormal error

After spring imports the database and c3p0 dependency package in idea, it will prompt the database for abnormal error

2022-02-03 00:42:17 CSDN Q & A

The phenomenon and background of the problem

Test code :

    @Test    public void test1() throws Exception {        // obtain C3P0 Database objects         ComboPooledDataSource ds = new ComboPooledDataSource();        ds.setDriverClass("com.mysql.cj.jdbc.Driver");        ds.setJdbcUrl("jdbc:mysql://localhost:3306/db");        ds.setDataSourceName("root");        ds.setPassword("1234");        Connection connection = ds.getConnection();        System.out.println(connection);        connection.close();    }

Error message :

 Warning : com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@57b6bfc7 -- 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). Last acquisition attempt exception: java.sql.SQLException: Access denied for user 'Lv'@'localhost' (using password: YES)    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:828)    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448)    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:161)    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:202)    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)    at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) December  17, 2021 8:48:27  Afternoon  com.mchange.v2.resourcepool.BasicResourcePool  Warning : Having failed to acquire a resource, com.mchange.v2.resourcepool[email protected]5f341870 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.java.sql.SQLException: Connections could not be acquired from the underlying database!    at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:118)    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:692)    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)    at com.datastudy.DataSourceTest.test1(DataSourceTest.java:20)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)    at com.intellij.junit4.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(JUnitStarter.java:58)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:1469)    at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)    at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:554)    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:758)    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:685)    ... 24 moreCaused by: java.sql.SQLException: Access denied for user 'Lv'@'localhost' (using password: YES)    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:828)    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448)    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)    at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:161)    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:161)    at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:147)    at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:202)    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)    at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)    at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)    at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696) Process ended , Exit code  -1
Operating environment 、 Software version and other information

WIN10、IDEA2019.3 Software MVN frame Spring

Tried solutions

Dependency added successfully

img

Change version 、 Add database permissions




Refer to the answer 1:

Access denied for user 'Lv'@'localhost' (using password: YES)
Incorrect password .




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030042160861.html

Random recommended