jdbc操作数据库四步骤:
public static void main(String[] args) throws ClassNotFoundException {
//1.加载驱动
Class.forName("com.mysql.jdbc.Driver");
try{
//2.连接数据库
Connection connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/data_base?useUnicode=true&characterEncoding=utf-8","root","root");
//3.创建一个statement对象
Statement statement = connection.createStatement();
//4.执行是SQL语句
int resultSet = statement.executeUpdate("update cus_info set name = '222' where age='111' ");
System.out.println(resultSet);
}catch (Exception e){
e.printStackTrace();
}
}