当前位置:网站首页>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
边栏推荐
- How to write the keywords in the cover and title? As we media, why is there no video playback
- QT Detailed explanation of pro file
- Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
- Set onedrive or Google drive as a drawing bed in upic for free
- SQLSERVER事物与锁的问题
- Llvm - generate if else and pH
- Role of asemi rectifier module mdq100-16 in intelligent switching power supply
- Async void caused the program to crash
- The difference between having and where in SQL
- C language super complete learning route (collection allows you to avoid detours)
猜你喜欢
Svn detailed use tutorial
Have you really learned the operation of sequence table?
每日一题-LeetCode396-旋转函数-递推
Nuxt project: Global get process Env information
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
Basic operation of circular queue (Experiment)
Mds55-16-asemi rectifier module mds55-16
Lotus DB design and Implementation - 1 Basic Concepts
Thread synchronization, life cycle
How to use OCR in 5 minutes
随机推荐
LeetCode167-两数之和II-双指针-二分-数组-查找
A series of problems about the best time to buy and sell stocks
On the day of entry, I cried (mushroom street was laid off and fought for seven months to win the offer)
Llvm - generate for loop
Set up an AI team in the game world and start the super parametric multi-agent "chaos fight"
8.2 text preprocessing
Thread synchronization, life cycle
My raspberry PI zero 2W tossing notes record some problems encountered and solutions
Have you learned the basic operation of circular queue?
The life cycle of key value in redis module programming
我的树莓派 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
2-GO variable operation
Borui data and F5 jointly build the full data chain DNA of financial technology from code to user
多语言通信基础 06 go实现grpc的四种数据流模式实现
Comment eolink facilite le télétravail
Reptile exercises (1)
Leetcode167 - sum of two numbers II - double pointer - bisection - array - Search
[untitled]
like和regexp差别
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]