executeBatch方法详解

PrepareStatement 也是接口
PrepareStatement extends Statement
PrepareStatement 本身没有 int[] executeBatch() throws SQLException 方法
而是继承了Statement的方法,且它们都是接口没有实际实现方法,但Statement
接口对executeBatch()方法做了规范
/**
     * Submits a batch of commands to the database for execution and
     * if all commands execute successfully, returns an array of update counts.
       每次提交一批命令到数据库中执行,如果所有的命令都成功执行了,那么返回一个
       数组,这个数组是说明每条命令所影响的行数
     * The <code>int</code> elements of the array that is returned are ordered
     * to correspond to the commands in the batch, which are ordered
     * according to the order in which they were added to the batch.
       返回的数组中每个整型值都是排过序的,它们的顺序和批量处理中的命令们是一致的,
       命令的顺序是按照它们被加到批处理中的顺序一致。
     * The elements in the array returned by the method <code>executeBatch</code>
     * may be one of the following:
       executeBatch方法返回的数组中的元素可能是下面几种情形之一:
     * <OL>
     * <LI>A number greater than or equal to zero -- indicates that the
     * command was processed successfully and is an update count giving the
     * number of rows in the database that were affected by the command's
     * execution
       一个大于或等于零的数字,简单说来命令成功执行后就返回它所影响到的行的数目
     * <LI>A value of <code>SUCCESS_NO_INFO</code> -- indicates that the command was
     * processed successfully but that the number of rows affected is
     * unknown
       
      * The constant indicating that a batch statement executed successfully
      * but that no count of the number of rows it affected is available.
      int SUCCESS_NO_INFO = -2;
      常量SUCCESS_NO_INFO代表的值=-2,也就是说命令执行成功了但命令影响到的行数
      无法统计,是未知的,只能返回SUCCESS_NO_INFO来说明命令执行情况。
     * <P>

你可能感兴趣的:(executeBatch)