public class DBUtils{
private Connection conn = null;
public void DBConnection(){
try{
DriverManager.registerDriver(new com.mysql.jdbc.Driver());
String url ="jdbc:mysql://localhost:3306/数据库名?serverTimezone=UTC";
String user="登录名";
String password="登录密码";
conn = DriverManager.getConnection(url, user, password);
}catch(SQLException e){
e.printStackTrace();
}
}
Java语言中如何连接mysql数据库
最新推荐文章于 2024-08-24 22:01:16 发布