zoukankan      html  css  js  c++  java
  • Statement batch update

    To perform a Statement batch update, you must turn off auto-commit. In Java(TM) Database Connectivity (JDBC), auto-commit is on by default. Auto-commit means any updates to the database are committed after each SQL statement is processed. If you want to treat a group of statements being handed to the database as one functional group, you do not want the database committing each statement individually. If you do not turn off auto-commit and a statement in the middle of the batch fails, you cannot roll back the entire batch and try it again because half of the statements have been made final. Further, the additional work of committing each statement in a batch creates a lot of overhead. See Transactions for more details.

    After turning off auto-commit, you can create a standard Statement object. Instead of processing statements with methods such as executeUpdate, you add them to the batch with the addBatch method. Once you have added all the statements you want to the batch, you can process all of them with the executeBatch method. You can empty the batch at anytime with the clearBatch method.

    The following example shows how you can use these methods:

    Example: Statement batch update

    Note: Read the Code example disclaimer for important legal information.


    Code

    In this example, an array of integers is returned from the executeBatch method. This array has one integer value for each statement that is processed in the batch. If values are being inserted into the database, the value for each statement is 1 (that is, assuming successful processing). However, some of the statements may be update statements that affect multiple rows. If you put any statements in the batch other than INSERT, UPDATE, or DELETE, an exception occurs.

       backtrack:https://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=/rzaha/batchstm.htm

  • 相关阅读:
    手脱UPX v0.89.6
    手脱ASPack v2.12
    为什么每次进入命令都要重新source /etc/profile 才能生效?
    解决maven update project 后项目jdk变成1.5
    关于dubbo服务的xml配置文件报错的问题
    dubbo实际应用中的完整的pom.xml
    部署Maven项目到tomcat报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener【转】
    web.xml配置文件中<async-supported>true</async-supported>报错
    eclipse在线安装maven插件
    centos安装eclise启动报错
  • 原文地址:https://www.cnblogs.com/jcleung/p/1446906.html
Copyright © 2011-2022 走看看