由于使用的是最新的驱动和最新的mysql版本, 网上的教程基本gg,内部原理又不会,所以整个连接过程如同吃屎了一般!还好我的聪明才智,最终找出了代码最终形态。(我也不知道为甚么这样写,反正能连上)
import java.sql.*;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.sql.*;
public class Main {
public static void main(String []argc) throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/DBTest?serverTimezone=UTC&useSSL=false";
Connection con = DriverManager.getConnection(url, "root", "123");
System.out.println("Done");
}
}