01: ///////////////////////////////////////////////////////////////////////////////
02: //
03: // Copyright (C) 2003-@year@ by Thomas M. Hazel, MyOODB (www.myoodb.org)
04: //
05: // All Rights Reserved
06: //
07: // This program is free software; you can redistribute it and/or modify
08: // it under the terms of the GNU General Public License and GNU Library
09: // General Public License as published by the Free Software Foundation;
10: // either version 2, or (at your option) any later version.
11: //
12: // This program is distributed in the hope that it will be useful,
13: // but WITHOUT ANY WARRANTY; without even the implied warranty of
14: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: // GNU General Public License and GNU Library General Public License
16: // for more details.
17: //
18: // You should have received a copy of the GNU General Public License
19: // and GNU Library General Public License along with this program; if
20: // not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
21: // MA 02139, USA.
22: //
23: ///////////////////////////////////////////////////////////////////////////////
24: package org.myoodb.simpleSsl;
25:
26: import org.myoodb.objects.*;
27:
28: public class Client {
29: public static int PORT = 54322;
30: public static String USERNAME = "admin";
31: public static String PASSWORD = "admin";
32:
33: public static void main(String args[]) throws Exception {
34: org.myoodb.MyOodbDatabase db = org.myoodb.MyOodbDatabase.open(
35: "tcps://localhost:" + PORT, USERNAME, PASSWORD);
36:
37: org.myoodb.collectable.LinkedList root = (org.myoodb.collectable.LinkedList) db
38: .getRoot("Persons");
39: if (root == null) {
40: root = (org.myoodb.collectable.LinkedList) db.createRoot(
41: "Persons",
42: "org.myoodb.collectable.LinkedListDbImpl");
43: //root = (org.myoodb.collectable.LinkedList) db.createRoot("Persons", org.myoodb.collectable.LinkedListDbImpl.class);
44: }
45:
46: Person person = (Person) db
47: .createObject("org.myoodb.objects.PersonDbImpl");
48: //Person person = (Person) db.createObject(PersonDbImpl.class);
49:
50: person.setName("John Smith the " + root.size());
51: root.add(person);
52:
53: System.out.println("New persons in database: " + person);
54:
55: java.util.Iterator iter = root.toArrayList().iterator();
56: while (iter.hasNext()) {
57: person = (Person) iter.next();
58:
59: long start = System.currentTimeMillis();
60: String name = person.getName();
61: long stop = System.currentTimeMillis();
62:
63: System.out.println(" - Existing persons in database: "
64: + name + " / getTime:" + (stop - start));
65: }
66: }
67: }
|