当前位置:网站首页>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
边栏推荐
- Fill in the next right node pointer II of each node [classical hierarchy traversal | regarded as linked list]
- Async keyword
- 脏读、不可重复读和幻读介绍
- How to write the keywords in the cover and title? As we media, why is there no video playback
- C语言超全学习路线(收藏让你少走弯路)
- Basic operation of sequential stack
- 我的 Raspberry Pi Zero 2W 折腾笔记,记录一些遇到的问题和解决办法
- Leetcode149 - maximum number of points on a line - Math - hash table
- Epoll's et, lt working mode -- example program
- Bingbing learning notes: take you step by step to realize the sequence table
猜你喜欢
Progress in the treatment of depression
About UDP receiving ICMP port unreachable
Leetcode153 - find the minimum value in the rotation sort array - array - binary search
What is the effect of Zhongfu Jinshi wealth class 29800? Walk with professional investors to make investment easier
分享 20 个不容错过的 ES6 的技巧
分布式事务Seata介绍
For 22 years, you didn't know the file contained vulnerabilities?
Tun equipment principle
Tun model of flannel principle
win10 任务栏通知区图标不见了
随机推荐
SQLSERVER事物与锁的问题
你还不知道责任链模式的使用场景吗?
博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
UML project example -- UML diagram description of tiktok
Redis cluster principle
Alexnet model
Don't you know the usage scenario of the responsibility chain model?
ffmpeg安装遇错:nasm/yasm not found or too old. Use --disable-x86asm for a crippled build.
Advanced application of I / O multiplexing: Processing TCP and UDP services at the same time
1-初识Go语言
Introduction to Arduino for esp8266 serial port function
What is the role of the full connection layer?
On the day of entry, I cried (mushroom street was laid off and fought for seven months to win the offer)
Detailed explanation of C language knowledge points - data types and variables [2] - integer variables and constants [1]
Have you learned the basic operation of circular queue?
1990年1月1日是星期一,定义函数date_to_week(year,month,day),实现功能输入年月日后返回星期几,例如date_to_week(2020,11,1),返回:星期日。 提示:
大文件如何快速上传?
Brute force of DVWA low -- > High
UML学习_day2
go基础 反射