mysql,批量插入的时候能不能用预编译该如何解决
1个回答
展开全部
内容:
Connection conn = ConnectionObject.getConnection();
String insql = "insert into students(sid,sname,sex,age,address,tel) values(?,?,?,?,?,?)";
if(conn != null){
try {
sta = conn.createStatement();
ps = conn.prepareStatement(insql);
ps.setString(1, "tzcs008");
ps.setString(2, "朱玉丽");
ps.setCharacterStream(3, sr,sex.length());
ps.setInt(4, 22);
ps.setString(5, "宁乡");
ps.setString(6,"15985633254");
ps.executeUpdate();
}
Connection conn = ConnectionObject.getConnection();
String insql = "insert into students(sid,sname,sex,age,address,tel) values(?,?,?,?,?,?)";
if(conn != null){
try {
sta = conn.createStatement();
ps = conn.prepareStatement(insql);
ps.setString(1, "tzcs008");
ps.setString(2, "朱玉丽");
ps.setCharacterStream(3, sr,sex.length());
ps.setInt(4, 22);
ps.setString(5, "宁乡");
ps.setString(6,"15985633254");
ps.executeUpdate();
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询