This article mainly introduces the solution to the problem of Failed when configuring IDEA to connect to MYSQL database, and shares it with you. The details are as follows: The error location is as follows We changed it and found that we could connect normally IDEA failed when trying to connect to MySQL When I try to connect to Mysql with IDEA, it always shows that the connection failed, and I only know that the connection object cannot be created. Most of the solutions on the Internet are to modify the connection characters, but in the end I found that it was not a problem with the connection string settings. Moreover, this error is easy to encounter for novices like me, so I share it here. = = Mysql version: Mysql 5.7 Connection jar package: mysql-connector-java-5.1.40-bin.jar The code is as follows: import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class Example11_1 { public static void main(String args[]) { Connection con = null; Statement sql; ResultSet rs; try { Class.forName("com.mysql.jdbc.Driver"); //Load JDBC_MySQL driver} catch (Exception e) { } String uri = "jdbc:mysql://localhost:3306/jdbc?useSSL=true"; String user = "root"; String password = "********"; try { con = DriverManager.getConnection(uri, user, password); //Connection code} catch (Exception e) { } try { sql = con.createStatement(); rs = sql.executeQuery("SELECT * FROM mess"); //Query the mess table} catch (Exception e) { System.out.println(e); }finally { //con.close(); } } } The reason was that the path of the Java project I created contained Chinese characters. Later, I tried to create a new project in the root directory and then connected it. //I'm so stupid. This is the end of this article about how to solve the problem of Failed when configuring IDEA to connect to MYSQL database. For more relevant content about configuring IDEA to connect to MYSQL, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Html easily implements rounded rectangle
>>: Nginx builds rtmp live server implementation code
It's easy to send messages to other users in ...
Table of contents What is the Picker component Pr...
1. Create a new user: 1. Execute SQL statement to...
Only display Docker container mount directory inf...
Format Encoding 1. Please set the page width with...
Table of contents Overview 1. How to animate a DO...
Every website usually encounters many non-search ...
Here we only focus on the installation and use of...
Table of contents 1. The concept of process and t...
Table of contents Implementing an irregular form ...
MySQL escape Escape means the original semantics ...
OBS studio is cool, but JavaScript is cooler. Now...
This article describes MySQL 8.0 user and role ma...
Table of contents Preface Do not use strings to s...
Related system calls for file operations create i...