/******************************************************************************/ /* File: datamanager.beh */ /* */ /* Describes the class that actually implements operations for connecting to */ /* the intended database, executing a specified SQL statement, and finally */ /* returning the result. For an Insert request, it throws an exception in */ /* case of a failure or does nothing. For a Query request, it throws an */ /* exception if there is a failure, or returns a vector of vectors */ /* representing the rows and columns. */ /* */ /******************************************************************************/ DataManager { {{ public DataManager(ConnectionArgs connArgs) { super(); } public Vector getData(String SQLStmt) throws Exception { if (SQLStmt.lastIndexOf("department") == -1) return cookUpData1(); else return cookUpData2(); } public Vector cookUpData1() { Vector row; Vector result = new Vector(); row = new Vector(); row.add(new Integer(25)); row.add(new String("Alan Alda")); row.add(new String("D01")); row.add(null); result.addElement(row); row = new Vector(); row.add(new Integer(100)); row.add(new String("Boris Becker")); row.add(new String("D01")); row.add(null); result.addElement(row); row = new Vector(); row.add(new Integer(30)); row.add(new String("Colin Cowdrey")); row.add(new String("D01")); row.add(new Integer(25)); result.addElement(row); row = new Vector(); row.add(new Integer(120)); row.add(new String("Doris Day")); row.add(new String("D01")); row.add(new Integer(25)); result.addElement(row); row = new Vector(); row.add(new Integer(10)); row.add(new String("Edna Edwards")); row.add(new String("D02")); row.add(new Integer(100)); result.addElement(row); row = new Vector(); row.add(new Integer(145)); row.add(new String("Fred Flintstone")); row.add(new String("D02")); row.add(new Integer(100)); result.addElement(row); row = new Vector(); row.add(new Integer(200)); row.add(new String("George Grahams")); row.add(new String("D02")); row.add(new Integer(100)); result.addElement(row); row = new Vector(); row.add(new Integer(33)); row.add(new String("Helen Hunt")); row.add(new String("D02")); row.add(new Integer(120)); result.addElement(row); row = new Vector(); row.add(new Integer(35)); row.add(new String("Irma Illingworth")); row.add(new String("D02")); row.add(new Integer(145)); result.addElement(row); row = new Vector(); row.add(new Integer(50)); row.add(new String("Jack Joseph")); row.add(new String("D03")); row.add(new Integer(145)); result.addElement(row); return result; } public Vector cookUpData2() { Vector row; Vector result = new Vector(); row = new Vector(); row.add(new String("D01")); row.add(new String("Accounts")); row.add(new Integer(25)); row.add(new String("Alan Alda")); row.add(new String("D01")); result.addElement(row); row = new Vector(); row.add(new String("D01")); row.add(new String("Accounts")); row.add(new Integer(10)); row.add(new String("Boris Becker")); row.add(new String("D01")); result.addElement(row); row = new Vector(); row.add(new String("D02")); row.add(new String("Purchases")); row.add(new Integer(20)); row.add(new String("Arthur Ash")); row.add(new String("D02")); result.addElement(row); row = new Vector(); row.add(new String("D02")); row.add(new String("Purchases")); row.add(new Integer(50)); row.add(new String("David Dunn")); row.add(new String("D02")); result.addElement(row); row = new Vector(); row.add(new String("D03")); row.add(new String("Marketing")); row.add(new Integer(15)); row.add(new String("Fred Flintstone")); row.add(new String("D03")); result.addElement(row); return result; } public void putData(String SQLStmt) throws Exception { return; } }} }