标签:names get test str cut values into new ...
public static void updat(String sql,Object...args) throws Exception{
Connection connection=null;
PreparedStatement preparedStatement=null;
try {
connection=getconnetion();
preparedStatement=(PreparedStatement) connection.prepareStatement(sql);
for(int i=0;i<args.length;i++){
preparedStatement.setObject(i+1, args[i]);
}
preparedStatement.executeUpdate();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
-----------------------------------------
测试
@Test
public void test2(){
Student student=new Student();
String sql="insert into users values(?,?,?)";
student.setId(5211314);
student.setNameString("Myongyuan");
student.setSconString("LaiShan");
try {
Tools.updat(sql, student.getId(),student.getNameString(),student.getSconString());
} catch (Exception e) {
e.printStackTrace();
}
}
标签:names get test str cut values into new ...
原文地址:http://www.cnblogs.com/afterhours/p/6108052.html