public synchronized void addTilesInBatch ( List < Tile > tilesList ) throws Exception { database . execOnConnection ( connection -> { boolean autoCommit = connection . getAutoCommit ( ) ; connection . setAutoCommit ( false ) ; try ( IHMPreparedStatement pstmt = connection . prepareStatement ( insertTileSql ) ; ) { for ( Tile tile : tilesList ) { pstmt . setInt ( 1 , tile . z ) ; pstmt . setInt ( 2 , tile . x ) ; pstmt . setInt ( 3 , tile . y ) ; pstmt . setBytes ( 4 , tile . imageBytes ) ; pstmt . addBatch ( ) ; } pstmt . executeBatch ( ) ; return "" ; } finally { connection . setAutoCommit ( autoCommit ) ; } } ) ; }
Add a list of tiles in batch mode .