zoukankan      html  css  js  c++  java
  • Batch批处理

     1 import java.sql.*;
     2 public class TestBatch {
     3 
     4 
     5     public static void main(String[] args) throws Exception {
     6         Class.forName("oracle.jdbc.driver.OracleDriver");
     7         Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.1:1521:SXT", "scott", "tiger");
     8         /*
     9         Statement stmt = conn.createStatement();
    10         stmt.addBatch("insert into dept2 values (51, '500', 'haha')");
    11         stmt.addBatch("insert into dept2 values (52, '500', 'haha')");
    12         stmt.addBatch("insert into dept2 values (53, '500', 'haha')");
    13         stmt.executeBatch();
    14         stmt.close();
    15         */
    16         
    17         PreparedStatement ps = conn.prepareStatement("insert into dept2 values (?, ?, ?)");
    18         ps.setInt(1, 61);
    19         ps.setString(2, "haha");
    20         ps.setString(3, "bj");
    21         ps.addBatch();
    22         
    23         ps.setInt(1, 62);
    24         ps.setString(2, "haha");
    25         ps.setString(3, "bj");
    26         ps.addBatch();
    27         
    28         ps.setInt(1, 63);
    29         ps.setString(2, "haha");
    30         ps.setString(3, "bj");
    31         ps.addBatch();
    32         
    33         ps.executeBatch();
    34         ps.close();
    35         
    36         conn.close();
    37 
    38     }
    39   //上面是两种statement进行批处理的例子
    40 }
  • 相关阅读:
    多项式乘法
    容斥计算多重组合
    D. Tokitsukaze, CSL and Stone Game
    优惠买商品(dp、greedy)
    数星星(单点更新,求前缀和)
    信息推送(单点更新,求前缀和)
    互相送礼物
    Codeforces Round #611 (Div. 3)E. New Year Parties
    多源bfs
    mysql事务和锁
  • 原文地址:https://www.cnblogs.com/elleniou/p/2640002.html
Copyright © 2011-2022 走看看