public static TableModel generateInternshipTable() { Database db = new Database("internship"); TableModel table = null; Vector<String> fields = new Vector<String>(); // Prepare the database query to be used to populate the table db.innerJoin("company"); db.innerJoin("career_path"); // Populating a map of my fields so that I can choose which columns to // display and what labels to display them as. fields.add("title"); fields.add("post_date AS posted"); fields.add("expiration AS expires"); fields.add("quantity AS positions"); // Use table.fieldname when querying multiple tables joined together fields.add("career_path.name AS career_path"); fields.add("company.name AS company"); try { // Generate the table from the query table = new TableModel(db.select(fields)); table.parseData(); } catch (Exception e) { System.out.println("Failed to load the internship table"); System.out.println(e.getMessage()); } return table; }
public static TableModel generateTable() { cis406.Database db = new cis406.Database("users"); TableModel table = null; Vector<String> fields = new Vector<String>(); // Prepare the database query to be used to populate the table db.innerJoin("status"); db.innerJoin("clearance"); // Populating a map of my fields so that I can choose which columns to // display and what labels to display them as. fields.add("user_name"); fields.add("first_name"); fields.add("last_name"); fields.add("failed_logon_attempts"); // Use table.fieldname when querying multiple tables joined together fields.add("status.description AS user_status"); fields.add("clearance.description AS user_type"); try { // Generate the table from the query table = new TableModel(db.select(fields)); table.parseData(); } catch (Exception e) { System.out.println("Failed to load the internship table"); System.out.println(e.getMessage()); } return table; }
public static TableModel generateStudentTable() { Database db = new Database("student"); TableModel table = null; Vector<String> fields = new Vector<String>(); // Prepare the database query to be used to populate the table db.innerJoin("major"); db.innerJoin("minor"); // Populating a map of my fields so that I can choose which columns to // display and what labels to display them as. Use null to not alias. fields.add("last_name AS LastName"); fields.add("first_name as FirstName"); fields.add("student_id AS StudentID"); fields.add("last_update AS updated"); // Use table.fieldname when querying multiple tables joined together fields.add("major.major_name AS major"); fields.add("minor.minor_name AS minor"); db.setOrderBy("last_name ASC"); fields.add("graduated AS Graduated"); try { // Generate the table from the query table = new TableModel(db.select(fields)); table.parseData(); } catch (Exception e) { System.out.println("Failed to load the student table"); System.out.println(e.getMessage()); } return table; }