1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| package cn.itcast.jdbc;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement;
public class JdbcDemo1 {
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/xscj?serverTimezone=UTC", "root", "123456");
String sql = "UPDATE XS SET 性别=0 WHERE 学号=081241";
Statement stmt = conn.createStatement();
int count = stmt.executeUpdate(sql);
System.out.println(count);
stmt.close(); conn.close();
}
}
|