mysql连接数据库
1.MySQL8.011
public class DBHelper {
//四个常量
protected static final String USER_NAME = "root";
protected static final String PASSWORD = "数据库密码";
protected static final String DRIVER = "com.mysql.jdbc.Driver";
protected static final String URL = "jdbc:mysql://localhost:3306/数据库名?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC";
protected static Connection coom = null;
//打开数据库的方法,返回类型为连接对象:Commection
public static Connection getCommection() {
try {
//加载数据库驱动
//Class.forName