private void executeBatch ( Results results , final List < String > queries ) throws SQLException { if ( ! options . useBatchMultiSend ) { String sql = null ; SQLException exception = null ; for ( int i = 0 ; i < queries . size ( ) && ! isInterrupted ( ) ; i ++ ) { try { sql = queries . get ( i ) ; writer . startPacket ( 0 ) ; writer . write ( COM_QUERY ) ; writer . write ( sql ) ; writer . flush ( ) ; getResult ( results ) ; } catch ( SQLException sqlException ) { if ( exception == null ) { exception = logQuery . exceptionWithQuery ( sql , sqlException , explicitClosed ) ; if ( ! options . continueBatchOnError ) { throw exception ; } } } catch ( IOException e ) { if ( exception == null ) { exception = handleIoException ( e ) ; if ( ! options . continueBatchOnError ) { throw exception ; } } } } stopIfInterrupted ( ) ; if ( exception != null ) { throw exception ; } return ; } initializeBatchReader ( ) ; new AbstractMultiSend ( this , writer , results , queries ) { @ Override public void sendCmd ( PacketOutputStream pos , Results results , List < ParameterHolder [ ] > parametersList , List < String > queries , int paramCount , BulkStatus status , PrepareResult prepareResult ) throws IOException { String sql = queries . get ( status . sendCmdCounter ) ; pos . startPacket ( 0 ) ; pos . write ( COM_QUERY ) ; pos . write ( sql ) ; pos . flush ( ) ; } @ Override public SQLException handleResultException ( SQLException qex , Results results , List < ParameterHolder [ ] > parametersList , List < String > queries , int currentCounter , int sendCmdCounter , int paramCount , PrepareResult prepareResult ) { String sql = queries . get ( currentCounter + sendCmdCounter ) ; return logQuery . exceptionWithQuery ( sql , qex , explicitClosed ) ; } @ Override public int getParamCount ( ) { return - 1 ; } @ Override public int getTotalExecutionNumber ( ) { return queries . size ( ) ; } } . executeBatch ( ) ; }
Execute list of queries not rewritable .