Code example for Statement

Methods: execute, getGeneratedKeys

0
			String quote= "\'";
			String sqlInsert = "INSERT INTO forms (f_id, s_id, fName) VALUES (nextval('f_seq')," +
				surveyId + "," +
				quote + formName + quote + ");";
			 
			statement.execute(sqlInsert, Statement.RETURN_GENERATED_KEYS);
			ResultSet rs = statement.getGeneratedKeys();
			if( rs.next()) {
				formId = rs.getInt(1);
			} 
		} catch (Exception e) {
			e.printStackTrace();
		} 
    } 
     
    /* 
     * Method to update the database entry for the form 
     * Adds the database keys for parent forms and parent questions 
     * @param connection the database connection 
     * @param model  
     */