![](https://box.kancloud.cn/edc5243abe53129ff8d96fb983fb863f_613x131.png)
![](https://box.kancloud.cn/6f9bbf366d3bef89d82b9ab57e816d92_614x103.png)
update.java
~~~
package zyw.crud;
import java.sql.*;
public class update {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
// 1、注册数据库的驱动
Class.forName("com.mysql.jdbc.Driver");
// 2.获取数据库连接
String url="jdbc:mysql://122.14.200.136:3306/javadb";
Connection connection = DriverManager.getConnection(url, "root", "6a133f0024");
//3.获取操作数据库的对象
Statement statement= connection.createStatement();
// String sql = "insert into xuesheng VALUES ('xs005','zhangsna','男',20,'贵州','计算机')";
// String sql="delete from xuesheng where xuehao='xs005'";
String sql="update xuesheng set nianling=21 where xuehao='xs001'";
int result=statement.executeUpdate(sql);
//4.遍历结果集,取出数据
System.out.println("影响条数:"+result);
//5.关闭对象
statement.close();
connection.close();
}
}
~~~