日常小笔记
接入步骤分为两步
一、加载注册驱动器
Class.forName(“com.mysql.jdbc.Driver”);
如果MySQL为8.0版本时为com.mysql.cj.jdbc.Driver
二、获取连接对象
String url = “jdbc:mysql://localhost(数据库地址):3306(端口号一般默认都是3306)/数据库名”;
String user = “root(用户名一般为root)”;
String password = “自己设置的密码”;
Connection con = DriverManager.getConnection(url,user,password);
制作Javaweb项目中数据库的接入
最新推荐文章于 2023-08-15 17:08:58 发布