private void doBatchUpdate ( PreparedStatement ps , Object [ ] args , Calendar cal ) throws SQLException { final int [ ] sqlTypes = new int [ args . length ] ; final Object [ ] objArrays = new Object [ args . length ] ; // build an array of type values and object arrays for ( int i = 0 ; i < args . length ; i ++ ) { sqlTypes [ i ] = _tmf . getSqlType ( args [ i ] . getClass ( ) . getComponentType ( ) ) ; objArrays [ i ] = TypeMappingsFactory . toObjectArray ( args [ i ] ) ; } final int rowCount = ( ( Object [ ] ) objArrays [ 0 ] ) . length ; for ( int i = 0 ; i < rowCount ; i ++ ) { for ( int j = 0 ; j < args . length ; j ++ ) { setPreparedStatementParameter ( ps , j + 1 , ( ( Object [ ] ) objArrays [ j ] ) [ i ] , sqlTypes [ j ] , cal ) ; } ps . addBatch ( ) ; } }
Build a prepared statement for a batch update .