private static void doInsert ( CallInfo callInfo , Table table , DataSet data ) { StringBuilder sql = new StringBuilder ( "INSERT INTO " ) ; List < String > tableColumns = table . getColumns ( ) ; int columnCount = tableColumns . size ( ) ; int [ ] paramIdx = new int [ columnCount ] ; int param = 0 ; Iterator < String > itr = tableColumns . iterator ( ) ; String col = itr . next ( ) ; paramIdx [ param ] = ++ param ; sql . append ( table . getName ( ) ) . append ( ' ' ) . append ( col ) ; while ( itr . hasNext ( ) ) { paramIdx [ param ] = ++ param ; col = itr . next ( ) ; sql . append ( ' ' ) . append ( col ) ; } sql . append ( ") VALUES (?" ) ; for ( int i = 1 ; i < columnCount ; i ++ ) { sql . append ( ",?" ) ; } sql . append ( ' ' ) ; dataSetOperation ( callInfo , table , data , sql . toString ( ) , paramIdx ) ; }
Utility method to perform actual data insertion .