public static Connection co;
public static Statement conn;
sql 语句的预编译写法
public int zeng(Model model)throws Exception{
String sql1="insert into xueshengInf values(?,?,?,?,?,?,?,?,?)";
PreparedStatement pre=co.prepareStatement(sql1);
pre.setString(1,'111');pre.setString(2,'111'a);pre.setString(3,'姓名');
pre.setString(4,'班级');pre.setString(5,model.lianxi1);pre.setString(6,model.lianxi2);
pre.setString(7,model.zhiye);pre.setString(8,model.jieshao);pre.setString(9,model.daoshi);
System.out.println("增"+pre.executeUpdate() );
//return pre.executeUpdate();
}
对比sql 语句的经典 写法
String sql1="insert into xueshengInf values('111','111','姓名','班级','联系方式1','联系方式2','职业方向','个人介绍','导师是谁')";
System.out.println("增"+conn.executeUpdate(sql1) );