Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/fencedb/base/Test1.java


1   
2   package org.fencedb.base;
3   
4   import org.odmg.Implementation;
5   import org.odmg.Database;
6   import org.odmg.ODMGException;
7   import org.odmg.Transaction;
8   import org.odmg.OQLQuery;
9   import org.odmg.DList;
10  
11  import org.apache.ojb.odmg.OJB;
12  
13  import java.io.File;
14  import java.io.FileReader;
15  import java.io.BufferedReader;
16  import java.util.Vector;
17  import java.util.StringTokenizer;
18  
19  /**
20   *  Description of the Class
21   *
22   * @author  vico
23   * @created  June 7, 2003
24   */
25  public class Test1
26  {
27  
28      /**
29       *Constructor for the Test object
30       *
31       * @param  file Description of the Parameter
32       */
33      Test1(String file)
34      {
35  
36          Vector v = null;
37          try {
38  
39              File f = new File(file);
40  
41              FileReader reader = new FileReader(f);
42              BufferedReader br = new BufferedReader(reader);
43  
44              v = new Vector();
45              String line = null;
46  
47              while ((line = br.readLine()) != null) {
48                  Club c = new Club();
49  
50                  c.setShortName(line.substring(8, 20).trim());
51  
52                  v.addElement(c);
53              }
54  
55          }
56          catch (Exception e) {
57              e.printStackTrace();
58          }
59  
60          // get odmg facade instance
61          Implementation odmg = OJB.getInstance();
62          Database db = odmg.newDatabase();
63          //open database
64          try {
65              db.open("default", Database.OPEN_READ_WRITE);
66          }
67          catch (ODMGException ex) {
68              ex.printStackTrace();
69          }
70  
71          try {
72  
73              // save all country objects read...
74              for (int i = 0; i < v.size(); i++) {
75                  Transaction tx = odmg.newTransaction();
76                  tx.begin();
77                  Club c = (Club)v.elementAt(i);
78                  tx.lock(c, Transaction.WRITE);
79                  tx.commit();
80              }
81  
82          }
83          catch (Throwable t) {
84              t.printStackTrace();
85          }
86  
87      }
88  
89  
90      /**
91       *  Description of the Method
92       *
93       * @param  args Description of the Parameter
94       */
95      public static void main(String args[])
96      {
97          new Test1(args[0]);
98      }
99  }
100