I am running a java application with MySQL as the DB server. DB is a AWS RDS. The MySQL connector is published under GNU/GPL so it has to be substituted with something more lenient. Maria DB client claimed to be compatible. But ever since MariaDB client is being used we are seeing the below intermittent issue during DB intensive activities:
Excption:-
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/Projectname] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection] with root cause
java.sql.SQLNonTransientConnectionException: (conn=1530488) Connection is closed
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:187)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.cmdPrologue(AbstractQueryProtocol.java:1940)
Caused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:48)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
Caused by: java.sql.SQLNonTransientConnectionException: Could not connect to address=(host=XXXXXXXXXX)(port=3306)(type=master) : (conn=1530487) could not load system variables
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:192)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1372)
I have tried increasing the time_wait and max_allowed_packet to the maximum allowed but the issue still exists.
Versions:-
MySQL - 5.7.26
MariaDB connector - 2.6.2
Just came across this, found an answer. On my side this was for an Aurora 1 MySQL DB (equiv to 5.6).
As per Diego Dupin in https://jira.mariadb.org/browse/CONJ-824:
only good solution is to use option `usePipelineAuth=false&useBatchMultiSend=false`
So your DB connection string might look like this:
jdbc:mysql://127.0.0.1:3307/mydbname?usePipelineAuth=false&useBatchMultiSend=false
More details:
Aurora proxy has a known race condition issue that results in skipping other
queries in proxy buffer. connection might be in hang waiting for query response.
During authentication, socket has a timeout, that will result throwing the error
you describe.
So if `usePipelineAuth` or `useBatchMultiSend` is enable, it might work ... or not.
All pipeline options (`usePipelineAuth` and `useBatchMultiSend`) must be disabled when using aurora.
Problem has been reported to aurora a few times without correction.
Related
Application: Java spring boot + mysql
Story:
application log showed "Could not open JDBC Connecton for transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure"
Recovery of the DB instance has been triggered since hardware problem occurred in RDS instance
After 10 mins, the recovery is done.
application log showed "Could not commit JDBC transaction; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed." instead of previous exception.
After 45 mins, application resumed normal without manual operations.
Questions:
Will restarting the application solve the problem instantly?
Manual operation might not be the best to resolve such problem. But if I want it be auto resumed shortly, anything I can do to the setting datasource properties? i.e. set spring.datasource.justswap.time-between-eviction-runs-millis shorter?
Current datasource setting:
spring.datasource.xxx.maxActive=700
spring.datasource.xxx.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.xxx.test-on-borrow=false
spring.datasource.xxx.test-while-idle=true
spring.datasource.xxx.time-between-eviction-runs-millis=3600000
spring.datasource.druid.stat-view-servlet.enabled=false
We are in process to upgrade our environments and which include weblogic server upgrade as well. Currently we have UAT running on Weblogic 10.3.6 which connect to database from one other application and we use SHA1 certificate for securing the connection.
Now we are upgrading to Weblogic 12.1.3 and using same certificate, server is not able to connect to database and giving below error,
Caused by: org.springframework.jdbc.UncategorizedSQLException: Executing query; uncategorized SQLException for SQL [SELECT * FROM DATAROOM]; SQL state [null]; error code [0]; java.security.PrivilegedActionException: weblogic.jdbc.extensions.ConnectionDeadSQLException: weblogic.common.resourcepool.ResourceDeadException: 0:weblogic.common.ResourceException: Could not create pool connection for datasource 'GOV-UDAM-VIEWER'. The DBMS driver exception was: [FMWGEN][SQLServer JDBC Driver]SSL handshake failed: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed; nested exception is java.sql.SQLException: java.security.PrivilegedActionException: weblogic.jdbc.extensions.ConnectionDeadSQLException: weblogic.common.resourcepool.ResourceDeadException: 0:weblogic.common.ResourceException: Could not create pool connection for datasource 'GOV-UDAM-VIEWER'. The DBMS driver exception was: [FMWGEN][SQLServer JDBC Driver]SSL handshake failed: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: timestamp check failed
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.batch.item.database.AbstractCursorItemReader.initializeConnection(AbstractCursorItemReader.java:427)
at org.springframework.batch.item.database.AbstractCursorItemReader.doOpen(AbstractCursorItemReader.java:402)
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139)
... 18 more
Caused by: java.sql.SQLException: java.security.PrivilegedAction
As per my understanding this error comes when server is expired but in this case server in valid and moreover our old UAT is able to connect to server.
Please help me to drill down this issue.
Not a solution, but rather a suggestion:
I remember having similar problems some time ago, the solution then was that the system clock on one of the servers (application or DB server, not sure anymore) was not set correctly. This was fixed by repairing the NTP daemon on the server, which for some reason or other stopped working some time before. It could be that the software update enforces stricter checks on the timestamp(s) involved, which causes the problem only to show after updating.
Please note, however, that this was not Java-related, but rather C#, and also a couple of years ago. So it might not apply to your case, or even be partially misremembered by me.
I have a jar that connects to a DB. The first time I connect to the machine, the jar runs fine, connects to the DB and queries the tables properly etc. However, when I try a second and third time etc, the jar begins to run but gets stuck when connecting to the DB and then I receive the following error:
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not
get JDBC Connection; nested exception is java.sql.SQLException: Cannot
create PoolableConnectionFactory (IO Error: Connection reset)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
I checked and there is no problem with the firewall. The strange part is that it works once but then stops working.
Make sure your database server is accepting connections from the Confluence server TCP address and user is authorized to connect.
I am facing this problem.
Stackstrace
2014-09-22 16:50:35,292 [main] WARN org.hibernate.cfg.SettingsFactory
- Could not obtain connection metadata org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (IO Error: Connection reset) at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
can any one please let me know the cause of this , oracle version is 11g
Your stack trace specifies that you are unable to connect to your database.
Make sure that your database server is listening on the correct port (1521 default).
Check your firewall or any setting that prevents you from accessing your database server
Check your dataSource settings for any errors.
If your database is an external one, make sure that the listener.ora is configured correctly.
After a SQL Server database restart, my Tomcat 6 Spring web applications receives an SQL exception on the first attempt to query the database. Note: Tomcat 6 has continued to run during the SQL Server restart and I'm using myBatis. The exception is as follows:
org.springframework.dao.DataAccessResourceFailureException:
Error querying database. Cause: java.sql.SQLException: I/O Error: Connection reset
Any subsequent queries execute fine (without exception). How can I prevent this exception on the first query?
Set up your pool to test connections before giving them to your application
use testOnBorrow=true and (for instance) validationQuery="select 1" in your db pool connection