Code example for Statement

Methods: execute, getGeneratedKeys

0
			Statement statement = connection.createStatement();
			String quote= "\'";
			String sqlInsert = "INSERT INTO surveys (s_id, sName) VALUES (nextval('s_seq')," +
				quote + surveyName + quote + ");";
			 
			statement.execute(sqlInsert, Statement.RETURN_GENERATED_KEYS);
			 
			// Get the unique database key for the survey and update the model 
			ResultSet rs = statement.getGeneratedKeys();
			if( rs.next()) {
				surveyId = rs.getInt(1);
			} 
    	} catch (Exception e) {
    		e.printStackTrace();	// TODO stop further processing if there are errors
    	} 
    } 
     
 
     
}