ex1.
String strqry="insert into test (col1,col2) values (?,?)";
PreparedStatement pstmt = con.prepareStatement(strqry);
pstmt.setString(1,"test1");
pstmt.setString(2, "123");
pstmt.addBatch();
pstmt.setString(1,"test2");
pstmt.setString(2, "456");
pstmt.addBatch();
pstmt.executeBatch();
ex2:
Statement stmt=con.createStatement();
stmt.addBatch("insert into test (col1,col2) values ('test1','123')");
stmt.addBatch("update test set col2='789' where col1='test4'");
stmt.executeBatch();
沒有留言:
張貼留言