Solution to the problem of Failed when configuring IDEA to connect to MYSQL database

Solution to the problem of Failed when configuring IDEA to connect to MYSQL database

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:
  • Detailed explanation of how to connect to MySQL database using Java in IntelliJ IDEA
  • Problems and solutions of error 08001 when linking to MySQL in IDEA and no table display after successful connection
  • JDBC-idea import mysql to connect java jar package (mac)
  • Problems and solutions for IDEA connecting to MySQL
  • IDEA reports an error when connecting to MySQL! Server returns invalid timezone. Go to tab and set serverTimezone property
  • Tutorial on how to connect and use MySQL 8.0 in IDEA's Maven project
  • IDEA uses properties configuration file to connect to MySQL database
  • Detailed diagram of IntelliJ IDEA connecting to MySQL database

<<:  Html easily implements rounded rectangle

>>:  Nginx builds rtmp live server implementation code

Recommend

Use iframe to display weather effects on web pages

CSS: Copy code The code is as follows: *{margin:0;...

Vue uses mixins to optimize components

Table of contents Mixins implementation Hook func...

Docker renames the image name and TAG operation

When using docker images, images with both REPOSI...

Detailed tutorial on installing MariaDB on CentOS 8

MariaDB database management system is a branch of...

Docker Compose practice and summary

Docker Compose can realize the orchestration of D...

How to install iso file in Linux system

How to install iso files under Linux system? Inst...

React implements the sample code of Radio component

This article aims to use the clearest structure t...

Implementation code for partial refresh of HTML page

Event response refresh: refresh only when request...

Detailed explanation of the update command for software (library) under Linux

When installing packages on an Ubuntu server, you...

Native JavaScript message board

This article shares the specific code of JavaScri...