JSP怎么使用PreparedStatement对象向两个表中插入数据
我建了两个PreparedStatement对象的实例,但只有第一个得到执行..为什么?PreparedStatementps,ps2;ps=con.prepareSta...
我建了两个PreparedStatement对象的实例,但只有第一个得到执行..为什么?
PreparedStatement ps,ps2;
ps=con.prepareStatement("insert into test values(?,?);");
ps.setString(1,"admin");
ps.setString(2,"5566");
ps.execute();
//================
ps.setString(1,"kaka");
ps.setString(2,"22");
ps.execute();
//===================
ps.setString(1,"ronaldo");
ps.setString(2,"9");
ps.execute();
//===================
ps2=con.prepareStatement("insert into test2 values(?,?);");
ps2.setString(1,"me");
ps2.setString(2,"520");
out.println("yeah!");
ps.close();
con.close(); 展开
PreparedStatement ps,ps2;
ps=con.prepareStatement("insert into test values(?,?);");
ps.setString(1,"admin");
ps.setString(2,"5566");
ps.execute();
//================
ps.setString(1,"kaka");
ps.setString(2,"22");
ps.execute();
//===================
ps.setString(1,"ronaldo");
ps.setString(2,"9");
ps.execute();
//===================
ps2=con.prepareStatement("insert into test2 values(?,?);");
ps2.setString(1,"me");
ps2.setString(2,"520");
out.println("yeah!");
ps.close();
con.close(); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询