public synchronized void insert ( Connection conn , T [ ] objects ) throws SQLException { StringBuilder sql = new StringBuilder ( "insert into " + name + " (" + listOfFields + ") values (?" ) ; for ( int i = 1 ; i < nColumns ; i ++ ) { sql . append ( ",?" ) ; } sql . append ( ")" ) ; PreparedStatement insertStmt = conn . prepareStatement ( sql . toString ( ) ) ; for ( int i = 0 ; i < objects . length ; i ++ ) { bindUpdateVariables ( insertStmt , objects [ i ] , null ) ; insertStmt . addBatch ( ) ; } insertStmt . executeBatch ( ) ; insertStmt . close ( ) ; }
Insert several new records in the table . Values of inserted records fields are taken from objects of specified array .