当前位置:网站首页>Nacos程序连接MySQL8.0+ NullPointerException
Nacos程序连接MySQL8.0+ NullPointerException
2022-04-23 15:06:00 【JUST DO YOU LIKE】
1、报错问题:Nacos改用MySQL存储后,启动Nacos服务出现报错
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2330)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at JDBC.Demo.main(Demo.java:15)
Caused by: java.lang.NullPointerException
at com.mysql.jdbc.ConnectionImpl.getServerCharset(ConnectionImpl.java:2997)
at com.mysql.jdbc.MysqlIO.sendConnectionAttributes(MysqlIO.java:1934)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1863)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1226)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284)
... 13 more
2、报错原因: mysql-connector-java mysql的Java驱动需要更新到8.0+
3、解决方案
- 在Pom中换到8.0+即可解决问题
<!-- mysql数据库驱动包 --> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.21</version> </dependency>
- 改用低版本,如5.7+,注意Nacos支持5.65版本以上的MySQL
版权声明
本文为[JUST DO YOU LIKE]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_36777191/article/details/124335708
边栏推荐
- tcp_ Diag kernel related implementation 1 call hierarchy
- Leetcode162 - find peak - dichotomy - array
- SQLSERVER事物与锁的问题
- Llvm - generate local variables
- Epoll's et, lt working mode -- example program
- MySQL error packet out of order
- Advanced version of array simulation queue - ring queue (real queuing)
- Select receives both normal data and out of band data
- Flink DataStream 类型系统 TypeInformation
- eolink 如何助力遠程辦公
猜你喜欢
Share 20 tips for ES6 that should not be missed
Swift protocol Association object resource name management multithreading GCD delay once
Tun equipment principle
Programming philosophy - automatic loading, dependency injection and control inversion
8.4 realization of recurrent neural network from zero
Introduction to Arduino for esp8266 serial port function
Progress in the treatment of depression
asp. Net method of sending mail using mailmessage
LeetCode167-两数之和II-双指针-二分-数组-查找
Openfaas practice 4: template operation
随机推荐
eolink 如何助力遠程辦公
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
LeetCode165-比较版本号-双指针-字符串
How do I open the win10 startup folder?
Share 20 tips for ES6 that should not be missed
For 22 years, you didn't know the file contained vulnerabilities?
January 1, 1990 is Monday. Define the function date_ to_ Week (year, month, day), which realizes the function of returning the day of the week after inputting the year, month and day, such as date_ to
脏读、不可重复读和幻读介绍
Go basic reflection
Set onedrive or Google drive as a drawing bed in upic for free
Bingbing learning notes: take you step by step to realize the sequence table
8.2 text preprocessing
Flink DataStream 类型系统 TypeInformation
Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
Share 3 tools, edit 5 works at home and earn more than 400
Tencent has written a few words, Ali has written them all for a month
Llvm - generate if else and pH
你還不知道責任鏈模式的使用場景嗎?
Provided by Chengdu control panel design_ It's detailed_ Introduction to the definition, compilation and quotation of single chip microcomputer program header file
填充每个节点的下一个右侧节点指针 II [经典层次遍历 | 视为链表 ]