import java.sql.*;
public class JDBCTest02{
public static void main(String[] args){
Statement stmt = null;
Connection conn = null;
try{
DriverManager.registerDriver(new com.mysql.cj.jdbc.Driver());
String url = "jdbc:mysql://192.168.1.105:3306/harenmu?serverTimezone = UTC";
String user = "root";
String password = "huang67259@";
conn = DriverManager.getConnection(url,user,password);
System.out.println(conn);
stmt = conn.createStatement();
System.out.println(stmt);
String sql = "update dept set dname = 'rengshibu',loc = 'nanjing' where deptno = 60";
int count = stmt.executeUpdate(sql);
System.out.println(count == 1 ? "success":"fail");
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
if(stmt != null){
stmt.close();
}
}catch(SQLException e){
e.printStackTrace();
}
try{
if(conn != null){
conn.close();
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
}