⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sendbatch.java

📁 比较实用的C++编程思想 有很多例子可以用
💻 JAVA
字号:
/* * This sample shows how to use the batching extensions. * In this example, we demonstrate the sue of the "sendBatch" API. * This allows the user to actually execute a set of batched * execute commands. * */// You need to import the java.sql package to use JDBCimport java.sql.*;// You need to import oracle.jdbc.driver.* in order to use the// API extensions.import oracle.jdbc.driver.*;class SendBatch{  public static void main (String args [])       throws SQLException  {    // Load the Oracle JDBC driver    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());    // Connect to the database    // You can put a database name after the @ sign in the connection URL.    Connection conn =      DriverManager.getConnection ("jdbc:oracle:oci8:@", "scott", "tiger");    Statement stmt = conn.createStatement ();    // Default batch value set to 50 for all prepared statements belonging    // to this connection.    ((OracleConnection)conn).setDefaultExecuteBatch (50);    PreparedStatement ps =      conn.prepareStatement ("insert into dept values (?, ?, ?)");        ps.setInt (1, 32);    ps.setString (2, "Oracle");    ps.setString (3, "USA");    // this execute does not actually happen at this point    System.out.println (ps.executeUpdate ());         ps.setInt (1, 33);    ps.setString (2, "Applications");    ps.setString (3, "Indonesia");    // this execute does not actually happen at this point    int rows = ps.executeUpdate ();          System.out.println ("Number of rows updated before calling sendBatch: "			+ rows);    // Execution of both previously batched executes will happen    // at this point. The number of rows updated will be    // returned by sendBatch.    rows = ((OraclePreparedStatement)ps).sendBatch ();    System.out.println ("Number of rows updated by calling sendBatch: "			+ rows);      ps.close ();    conn.close ();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -