JDBC连接Mysql数据库的配置
//1.注册驱动
Class.forName("com.mysql.jdbc.Driver");
//2.获取连接
String url="jdbc:mysql://127.0.0.1:3306/dbtest1?useSSL=false";
String username="root";
String password="123456";
Connection conn = DriverManager.getConnection(url, username, password);
//3.定义sql
String sql="update students set name='王五' where id=1002";
//4.获取执行sql的对象 statement
Statement statement = conn.createStatement();
//5.执行sql
int count = statement.executeUpdate(sql);//受影响的行数
//6.处理结果
System.out.println(count);
//7.释放结果
statement.close();
conn.close();