1.导入jar包
2.连接的驱动地址为"com.mysql.cj.jdbc.Driver"
Class.forName("com.mysql.cj.jdbc.Driver");
3.创建连接(修改)
Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/a?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true","root"
,"123456");
4.定义sql
String sql="update account set balance=balance+500 where id=1";
5.获取执行sql的对象 stmt
Statement stmt = con.createStatement();
6.执行sql
int count = stmt.executeUpdate(sql);