MySQL 8.0 druid connection when calling Getservercharset Null pointer exception resolution method

Source: Internet
Author: User

Similar error messages are as follows:

16:52:01.163 [druid-connectionpool-create-1641320886] ERROR com.alibaba.druid.pool.druiddatasource-create Connection error, url:jdbc:mysql://localhost:3306/jf?useunicode=true&characterencoding=utf-8& Zerodatetimebehavior=converttonull&allowmultiqueries=true
Com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:Could not the Create connection to database server.

At Sun.reflect.GeneratedConstructorAccessor26.newInstance (Unknown Source) ~[?:?] At Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Delegatingconstructoraccessorimpl.java:45) ~[?:1.8.0_144]at java.lang.reflect.Constructor.newInstance (Constructor.java:423) ~[?:1.8.0_144]at com.mysql.jdbc.Util.handleNewInstance (Util.java:408) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.Util.getInstance (Util.java:383) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.SQLError.createSQLException (Sqlerror.java:1023) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.SQLError.createSQLException (Sqlerror.java:997) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.SQLError.createSQLException (Sqlerror.java:983) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.SQLError.createSQLException (Sqlerror.java:928) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.ConnectionImpl.connectOneTryOnly (Connectionimpl.java:2576) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.ConnectionImpl.createNewIO (Connectionimpl.java:2309) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.connectionimpl.<init> (Connectionimpl.java:834) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.jdbc4connection.<init> (Jdbc4connection.java:(~[mysql-connector-java-)5.1.32.jar:?] At Sun.reflect.GeneratedConstructorAccessor23.newInstance (Unknown Source) ~[?:?] At Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Delegatingconstructoraccessorimpl.java:45) ~[?:1.8.0_144]at java.lang.reflect.Constructor.newInstance (Constructor.java:423) ~[?:1.8.0_144]at com.mysql.jdbc.Util.handleNewInstance (Util.java:408) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.ConnectionImpl.getInstance (Connectionimpl.java:419) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.NonRegisteringDriver.connect (nonregisteringdriver.java:344) ~[ Mysql-connector-java-5.1.32.jar:?] At Com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection (Druidabstractdatasource.java:1375) ~[druid-1.0.11.jar:1.0.11]at Com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection (Druidabstractdatasource.java:1431) ~[druid-1.0.11.jar:1.0.11]at Com.alibaba.druid.pool.druiddatasource$createconnectionthread.run (Druiddatasource.java: 1857) [Druid-1.0.11.jar:1.0.11] 

caused by:java.lang.NullPointerException

At Com.mysql.jdbc.ConnectionImpl.getServerCharset (Connectionimpl.java:3299) ~[mysql-connector-java-5.1.32.jar:?]  At Com.mysql.jdbc.MysqlIO.sendConnectionAttributes (mysqlio.java:1967) ~[ Mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication (mysqlio.java: 1893) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.MysqlIO.doHandshake (mysqlio.java:1287) ~[mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.ConnectionImpl.coreConnect (connectionimpl.java:2494) ~[ Mysql-connector-java-5.1.32.jar:?] At Com.mysql.jdbc.ConnectionImpl.connectOneTryOnly (connectionimpl.java:2527) ~[ Mysql-connector-java-5.1.32.jar:?] ... 12 more             
The problem is not resolved on the Internet, the problem is solved by using MySQL connector version 8. So it should be a problem with the MySQL driver version. 8.0 some variations on the drive class and connection string are as follows:

Jdbc.driverclassname=com.mysql.cj.jdbc.driver
jdbc.url=jdbc:mysql://localhost:3306/k3c?useunicode=true&characterencoding=utf8&usessl=false& Servertimezone=hongkong

MySQL 8.0 druid connection when calling Getservercharset Null pointer exception resolution method

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.