jdbc mysql删除操作例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public static final String DBDRIVER="org.gjt.mm.mysql.Driver";
public static final String DBURL="jdbc:mysql://localhost:3306/sjk";
public static final String DBUSER="root";
public static final String DBPASSWORD="10000";
public static void main(String[] args) throws Exception {
//创建
Class.forName(DBDRIVER);
//连接
Connection con = DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
//操作
String del="DELETE FROM users WHERE name is null";
Statement stmt = con.createStatement();
stmt.executeUpdate(del);
System.out.println("删除成功");
stmt.close();
//关闭
con.close();
}
扫一扫,打赏我
Fanyun Fanyun
Copyright©1993 - Now. 瞎塔码搞