Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if java can't connect to mysql8.0?

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is to share with you what to do if java can't connect to mysql8.0. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

This article shares the collection of problems that java can't connect to MySQL8.0 for your reference. The details are as follows.

Question 1:Client does not support authentication protocol requested by Server; …

Question 2:Unknown initial character set index '255' received from server...

Necessary url statement for problem 3:MySQL8.0 connection

Question 4: duplicate calling methods

Operation question 1:

Solution: (3 sentences note semicolon, wy123456 is the password of my database)

Question 2:

Solution: (repeat package deletion)

The introduction is also deleted, leaving only the correct:

Then restart eclipse! The environment will be updated ~

Key: MySQL8.0 should add this sentence:? useSSL=false&serverTimezone=UTC

Public static String dbUrl= "jdbc:mysql://localhost:3306/websql?useSSL=false&serverTimezone=UTC"

Running result:

Question 4:

Solution: (the second connection, the name should be different)

Running result:

Attach the connection DbUtil class:

Package com.cungudafa;import java.sql.Connection;import java.sql.DriverManager;public class DbUtil {public static String dbUrl= "jdbc:mysql://localhost:3306/websql?useSSL=false&serverTimezone=UTC"; public static String dbUserName= "root"; public static String dbPassword= "wy123456"; public static String jdbcName= "com.mysql.jdbc.Driver"; public static Connection getCon () throws Exception {Class.forName (jdbcName); Connection con=DriverManager.getConnection (dbUrl,dbUserName,dbPassword); return con } public static void closeCon (Connection con) {try {if (con! = null) {con.close ();}} catch (Exception e) {e.printStackTrace ();} Thank you for reading! This is the end of the article on "what if java is not connected to mysql8.0". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report