JDBC操作数据库的基本步骤

介绿下JDBC的基本操作步骤。谢谢!
2024-12-21 12:41:28
推荐回答(2个)
回答1:

1.加载数据库连接驱动
2.创建连接
3.打开连接
4.创建sql
5.执行操作
6.返回操作结果
7.关闭连接

回答2:

String user = "root";
String password = "admin";
String url = "jdbc:mysql://localhost:3306/"+db;
String driver = "com.mysql.jdbc.Driver";
//String driver = "org.gjt.mm.mysql.Driver";
Class.forName(driver);
conn = DriverManager.getConnection(url, user, password);
mysql连接语句