Tag Archives: Connections could not be acquired from the underlying database!

Solutions to database connection problems: “connections could not be acquired from the underlying database!”

Solutions to database connection problems: “connections could not be acquired from the underlying database!”

 

1. When learning spring security, use the correct account and password to log in successfully. When viewing user management, an error is reported

 

2. After various searches, I found that none of them could solve my problem

 

3. Later, I compared the data of “database connection pool” between projects

The problem is solved by replacing “usessl = true” in JDBC URL with “usessl = false”

 

 

 

  database.properties

1 driverClass=com.mysql.jdbc.Driver
2 jdbcUrl=jdbc:mysql://localhost:3306/ssm_order?useSSL=false&useUnicode=true&characterEncoding=utf8
3 user=root
4 password=111111

 

4. Summarize the difference between usessl = false or true:

SSL protocol provides services mainly:

1) authenticate the user server to ensure that the data is sent to the correct server; .
2) encrypt data to prevent it from being stolen and used during data transmission
3) maintain data integrity and verify whether data is lost during transmission
currently, two layers of SSL protocol are supported:
SSL record protocol: the establishment relies on the transmission protocol (TCP) high-level protocol to provide basic functions such as data encapsulation, compression and encryption. Support
SSL handshake protocol: the establishment of SSL record protocol is used for identity authentication, negotiation of encryption algorithm and Exchange encryption keys, etc

When connecting with MySQL, the higher version of MySQL needs to indicate whether to connect with SSL.

It is not recommended to establish an SSL connection without server authentication, and the explicit option must be set, because the versions after mysql5.7 default usessl = true, so you need to explicitly disable SSL by setting usessl = false;

 

Or set usessl = true and provide a trust store for server certificate validation.

 

Reference article: https://blog.csdn.net/qq_ 45151059/article/details/114297848

[Solved] Connections could not be acquired from the underlying database!

Connections could not be acquired from the underlying database! // Unable to connect to the currently configured database tns-12541: TNS: no listener// no listener tns-12560: TNS: protocol adapter error// protocol adapter error tns-00511: no listener// no listener

Foreword:
in the development environment, the project runs normally, the sudden landing page can be displayed, and the landing operation is abnormal
query background log, error description:

Caused by: java.sql.SQLException: Connections could not be acquired from the underlying 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 org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:56)
	at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
	... 148 more
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)
	... 151 more  

Some time ago, the project was running normally, but there was a problem this afternoon, which indicates that the program configuration is normal, and it is also normal to check the number of database connections. This problem can only occur in the database

Use the database connection tool to connect, find the monitoring problem, TNS view the monitoring situation

lsnrctl status

The questions are as follows:

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 07-Dec-2018 18:22:47

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
TNS-12541: TNS:no listener  
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=GCRM0CV1)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused

The problem may be that there is a problem with the listening configuration file, but the listening configuration file has not been adjusted during this period of time. After checking the listening configuration file, there is no problem. Continue to investigate

Stop listening

lsnrctl stop

The problem is the same as described above

Start monitoring

lsnrctl start  

The questions are as follows:

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 07-11月-2018 18:23:22

Copyright (c) 1991, 2007, Oracle.  All rights reserved.

Starting /home/db/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.4.0 - Production
NL-00280: error creating log stream /home/db/oracle/product/10.2.0/db_1/network/log/listener.log
 NL-00278: cannot open log file
  SNL-00016: snlfohd: error opening file
   Linux Error: 13: Permission denied

Listener failed to start. See the error message(s) above...

View log:

ls -lh /home/db/oracle/product/10.2.0/db_1/network/log/listener.log 

It is found that the log size is larger than 4G, and the problem is found. This is the Oracle bug. When the listner log grows to 4GB, it is very slow to connect through the listener

Solution:

1. lsnrctl enters interactive mode  
2. execute set current_listener LISTENER  
3. set log_status off  
4. stop stop the listener  
5. manually delete the listener.log file under the specified listener log path  
6. start start the listener  
7. status Check the status