package JDBC;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class MySQL {
public static void main(String[] args) throws Exception {
//导入驱动jar包
//2.注册驱动
Class.forName("com.mysql.jdbc.Driver");
//3.获取数据库的连接对象
Connection conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/first","root","root");
//4.定义SQL语句
String sql="update emp set salary=20000 where id=1001 ";
//5.获取执行sql的对象 Statement
Statement stmt= conn.createStatement();
//6.执行sql
int count=stmt.executeUpdate(sql);
//7.处理结果
System.out.println(count);
//8.释放资源
stmt.close();
conn.close();
}
}