0

I'm unable to start a service that uses mysql due to some connection issue. Below is the stacktrace for the same -

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.\n\tat sun.reflect.GeneratedConstructorAccessor68.newInstance(Unknown Source)\n\tat sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\n\tat java.lang.reflect.Constructor.newInstance(Constructor.java:423)\n\tat com.mysql.jdbc.Util.handleNewInstance(Util.java:389)\n\tat com.mysql.jdbc.Util.getInstance(Util.java:372)\n\tat com.mysql.jdbc.SQLError.createSQLException(SQLError.java:958)\n\tat com.mysql.jdbc.SQLError.createSQLException(SQLError.java:937)\n\tat com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)\n\tat com.mysql.jdbc.SQLError.createSQLException(SQLError.java:872)\n\tat com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2149)\n\tat com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2074)\n\tat com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:794)\n\tat com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:44)\n\tat sun.reflect.GeneratedConstructorAccessor66.newInstance(Unknown Source)\n\tat sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\n\tat java.lang.reflect.Constructor.newInstance(Constructor.java:423)\n\tat com.mysql.jdbc.Util.handleNewInstance(Util.java:389)\n\tat com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)\n\tat com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)\n\tat com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:146)\n\tat com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:195)\n\tat com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:184)\n\tat com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:200)\n\tat com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1086)\n\tat com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1073)\n\tat com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:44)\n\tat com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1810)\n\tat com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)\nCaused by: java.lang.NullPointerException: null\n\tat com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2989)\n\tat com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1873)\n\tat com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1802)\n\tat com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1206)\n\tat com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2239)\n\tat com.mysql.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:2090)\n\t... 18 common frames omitted\n"

Respective entries in application.properties file is -

hibernate.connection.url=jdbc\:mysql\://localhost\:3306/localdb?autoReconnect=true
hibernate.connection.username=root
hibernate.connection.password=testpd
hibernate.showSql=true
hibernate.formatSql=true
hibernate.c3p0.min_size=20
hibernate.c3p0.max_size=200
hibernate.c3p0.checkout.timeout.config=10000
5
  • What MySQL connector are you using? Try looking here. Commented Dec 21, 2021 at 17:53
  • Thanks for your response,now getting a different set of exceptions: `org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChainProxy': Cannot resolve reference to bean 'org.springframework.security.filterChains' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': contd... Commented Dec 22, 2021 at 9:45
  • Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#65' while setting bean property 'sourceList' with key [65]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#65': Cannot create inner bean '(inner bean)#733' of type [org.springframework.security.web.authentication.www.BasicAuthenticationFilter] while setting constructor argument with key;nested exception is org.springframework.beans.factory.BeanCreationException` Commented Dec 22, 2021 at 9:48
  • You are using a too old version of MySQL Connector/J while attempting to connect to MySQL 8. Upgrade to MySQL Connector/J 8.0.x, or at minimum to 5.1.46 or higher. Your question is a duplicate of Java: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server Commented Dec 22, 2021 at 10:44
  • As an aside, this is not a timeout (as you seem to think given your question title). Commented Dec 22, 2021 at 10:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.