1.导入JAR包
2.创建数据库连接对象
3。定义SQL语言
4。获取执行对象
5.执行对象
6.处理结果
实例:
Class.forName(“com.mysql.jdbc.Driver”);
Connection conn= DriverManager.getConnection(“jdbc:mysql://localhost:3306/student”,“root”,“123456”);
String aql=“update usertab set age =50 where id=1”;
Statement stat =conn.createStatement();
int count=stat.executeUpdate(aql);
System.out.println(count);
stat.close();
conn.close();
jdbc
最新推荐文章于 2025-05-26 16:26:15 发布