MySQL第二天

//连接数据库的基本语句
public static void main(String[] args) throws Exception{

//1.注册驱动
Class.forName("com.mysql.jdbc.Driver");
//2.获取数据库连接对象
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/girl","root","root");
//3.定义sql语句
String sql = "update yang set ename='杨木'where id = 1001";
//4.获得执行sql语句
Statement stat = con.createStatement();
//5.执行
int i =stat.executeUpdate(sql);
System.out.println(i);
stat.close();
con.close();
}
posted @ 2019-04-08 20:13  顾与南歌`  阅读(120)  评论(0编辑  收藏  举报