public synchronized void insert ( Connection conn , T obj ) 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 ( ) ) ; bindUpdateVariables ( insertStmt , obj , null ) ; insertStmt . executeUpdate ( ) ; insertStmt . close ( ) ; }
Insert new record in the table . Values of inserted record fields are taken from specified object .