private void executeInternalBatch ( int size ) throws SQLException { executeQueryPrologue ( true ) ; results = new Results ( this , 0 , true , size , false , resultSetScrollType , resultSetConcurrency , autoGeneratedKeys , protocol . getAutoIncrementIncrement ( ) ) ; if ( protocol . executeBatchClient ( protocol . isMasterConnection ( ) , results , prepareResult , parameterList , hasLongData ) ) { return ; } //send query one by one, reading results for each query before sending another one SQLException exception = null ; if ( queryTimeout > 0 ) { for ( int batchQueriesCount = 0 ; batchQueriesCount < size ; batchQueriesCount ++ ) { protocol . stopIfInterrupted ( ) ; try { protocol . executeQuery ( protocol . isMasterConnection ( ) , results , prepareResult , parameterList . get ( batchQueriesCount ) ) ; } catch ( SQLException e ) { if ( options . continueBatchOnError ) { exception = e ; } else { throw e ; } } } } else { for ( int batchQueriesCount = 0 ; batchQueriesCount < size ; batchQueriesCount ++ ) { try { protocol . executeQuery ( protocol . isMasterConnection ( ) , results , prepareResult , parameterList . get ( batchQueriesCount ) ) ; } catch ( SQLException e ) { if ( options . continueBatchOnError ) { exception = e ; } else { throw e ; } } } } if ( exception != null ) { throw exception ; } }
Choose better way to execute queries according to query and options .