package lianxi;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class lianxi {
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver");
// 3:获取数据库连接对象
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/a","root","root");
// System.out.println(con);
// 4:定义sql 语句
String sql = "update product set sname='白小龙' where id=6";
// 5: 获得执行sql语句对象 Statement
Statement st = con.createStatement();
// 6: 执行sql 语句
int ou = st.executeUpdate(sql);
// 7 处理结果
System.out.println(ou);
// 8 释放资源
st.close();
con.close();
}
}