时间:2021-07-01 10:21:17 帮助过:17人阅读
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class TestJDBC {
public static void main(String[] args) {
String URL = "jdbc:mysql://localhost:3306/test?serverTimezone=GMT";
//?serverTimezone=GMT
//serverTimezone=GMT
String USER = "root";
String PASSWORD = "root";
Connection conn = null;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
System.out.println("连接成功");
try {
conn = DriverManager.getConnection(URL, USER, PASSWORD);
} catch (SQLException e) {
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
JDBC连接数据库随笔
标签:import mys str roo ati main com trace name