home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-27 | 4.1 KB | 113 lines |
- import java.util.Date;
- import employee;
-
- // mock-up of "sample database.mdb" used in DAOSample and RDOSample
- public class sample_database
- {
- // Array of employee records
- employee db[];
- private int length = 31;
-
- // Constructor which initialize the "database"
- sample_database()
- {
- db = new employee[length];
- db[0] = new employee("Maria Anders","mariaa","chrisp",
- "x4321","GL-30","May 1, 92",false);
- db[1] = new employee("Ana Trujillo","anat","thomash",
- "x4629","GL-14","Aug 14, 92",true);
- db[2] = new employee("Antonio Moreno","antoniom","annd",
- "x3932","GL-12","Apr 1, 92",false);
- db[3] = new employee("Thomas Hardy","thomash","pedroa",
- "x7788","GL-22","May 3, 93",true);
- db[4] = new employee("Christina Berglund","chrisb","mariaa",
- "x0921","GL-32","Dec 18, 92",true);
- db[5] = new employee("Hanna Moos","hannam","chrisp",
- "x0621","KJ-33","Oct 17, 93",false);
- db[6] = new employee("FrΘdΘrique Citeaux","fredc","annd",
- "x8860","GL-13","Jan 2, 94",true);
- db[7] = new employee("Martφn Sommer","martins","mariaa",
- "x2282","GL-36","Mar 5, 94",true);
- db[8] = new employee("Laurence Lebihan","larryl","annd",
- "x4540","GL-14","Nov 15, 94",false);
- db[9] = new employee("Elizabeth Lincoln","elizl","pedroa",
- "x4729","GL-29","Sep 23, 91",false);
- db[10] = new employee("Chris Park","chrisp","chrisp",
- "x1212","KJ-30","Feb 14, 91",false);
- db[11] = new employee("Patricio Simpson","patricios","thomash",
- "x5785","GL-11","May 30, 94",true);
- db[12] = new employee("Francisco Chang","franc","chrisp",
- "x3392","KJ-34","Jun 1, 92",false);
- db[13] = new employee("Yang Wang","yangw","annd",
- "x6545","GL-16","Mar 30, 92",true);
- db[14] = new employee("Pedro Afonso","pedroa","mariaa",
- "x7647","GL-20","Feb 24, 92",true);
- db[15] = new employee("Elizabeth Brown","lizb","pedroa",
- "x2382","GL-27","Sep 28, 95",false);
- db[16] = new employee("Sven Ottlieb","sveno","chrisp",
- "x9123","KJ-24","Mar 30, 94",false);
- db[17] = new employee("Janine Labrune","janinel","sveno",
- "x0678","KJ-27","Jun 17, 94",false);
- db[18] = new employee("Ann Devon","annd","mariaa",
- "x0297","GL-10","Apr 22, 91",true);
- db[19] = new employee("Roland Mendel","rolandm","annd",
- "x3425","GL-17","Aug 31, 92",true);
- db[20] = new employee("Aria Cruz","ariac","sveno",
- "x9857","KJ-26","May 23, 94",true);
- db[21] = new employee("Diego Roel","diegor","peterf",
- "x9444","KJ-22","Jun 23, 93",false);
- db[22] = new employee("Martine RancΘ","martiner","sveno",
- "x1016","KJ-25","Jul 20, 92",false);
- db[23] = new employee("Maria Larsson","marial","peterf",
- "x0695","KJ-21","May 13, 91",true);
- db[24] = new employee("Peter Franken","peterf","chrisp",
- "x7310","KJ-20","Jul 22, 92",false);
- db[25] = new employee("Carine Schmitt","carines","mariaa",
- "x3211","GL-33","Jun 3, 91",false);
- db[26] = new employee("Paolo Accorti","paoloa","pedroa",
- "x8260","GL-26","May 17, 93",true);
- db[27] = new employee("Lino Rodriguez ","linar","pedroa",
- "x2534","GL-23","Oct 21, 91",true);
- db[28] = new employee("Eduardo Saavedra","eduardos","peterf",
- "x4560","KJ-23","Mar 22, 93",false);
- db[29] = new employee("JosΘ Pedro Freyre","josepf","thomash",
- "x5828","GL-15","Jul 15, 91",false);
- db[30] = new employee("AndrΘ Fonseca","andref","sveno",
- "x9482","KJ-29","Aug 19, 93",true);
- }
-
- // Imitate a Select where email=[parameter]
- public employee find(String email)
- {
- for(int i = 0; i < length; i++)
- if(db[i].email.equals(email))
- return db[i];
- return null;
- }
-
- // Imitate a Select where manager=[parameter]
- public String[] findReports(String mgr)
- {
- // Create a temporary holding String array
- String temp[] = new String[15];
- int count = 0;
-
- // Search the "database" for matching records
- for(int i = 0; i < length; i++)
- if(db[i].manager.equals(mgr))
- {
- temp[count] = db[i].email;
- count ++;
- }
-
- // Create an array that is just the right size
- String result[] = new String[count];
-
- // Copy the found records in to the result array
- for(int i = 0; i < count; i++)
- result[i] = temp[i];
-
- return result;
- }
- }
-