用jdbc技术实现连接mysql数据库。
SQL/Test1.java
package cn.antraces.SQL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Test1 { public static void main (String[] args) throws ClassNotFoundException, SQLException { Class.forName("com.mysql.cj.jdbc.Driver"); Connection connection = DriverManager.getConnection( "jdbc:mysql://127.0.0.1:3306/mysql?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT", "root", "wodiu"); System.out.println(connection); } }
参考:
https://blog.csdn.net/Yuz_99/article/details/90201265
https://blog.csdn.net/hwt1070359898/article/details/90517291
https://repo1.maven.org/maven2/mysql/mysql-connector-java