package com.gylhaut.db;
import java.sql.Connection;
import java.sql.DriverManager;
public class DBUtil {
// databaseweb数据库名称
private static final String URL = "jdbc:mysql://localhost:3306/databaseweb";
private static final String NAME = "root";
private static final String PASSWORD = "123456";
private static Connection conn = null;
static {
try {
// 1.加载驱动程序
Class.forName("com.mysql.jdbc.Driver");
// DriverManager.registerDriver(new com.mysql.jdbc.Driver());
// 2.获得数据库的连接
conn = DriverManager.getConnection(URL, NAME, PASSWORD);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Connection getConnection(){
return conn;
}
}