home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-04-23 | 1.7 KB | 68 lines |
- package COM.odi.demo.pport;
-
- /**
- * <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
- *
- * Load the data into the database, from the text files.
- */
-
- import COM.odi.*;
-
- final
- public class Load
- {
-
- public static void main(String argv[]) throws java.io.IOException
- {
- String host = System.getProperty("COM.odi.host");
- String dbpath = System.getProperty("port.dbpath");
- String datadir = System.getProperty("port.datadir");
- String security = System.getProperty("port.security");
- String portfolio = System.getProperty("port.portfolio");
- String large = System.getProperty("port.large");
-
- if ((security == null) || (portfolio == null)) {
- if (datadir == null) {
- datadir = ".";
- }
-
- if (large == null) {
- security = datadir + java.io.File.separator + "smallstocktab.txt";
- portfolio = datadir + java.io.File.separator + "smallportfoliotab.txt";
- } else {
- security = datadir + java.io.File.separator + "stocktab.txt";
- portfolio = datadir + java.io.File.separator + "portfoliotab.txt";
- }
- }
-
- if (dbpath == null)
- dbpath = "port.odb";
-
- System.out.println("DMA server host = " + host);
- System.out.println("DB pathname = " + dbpath);
- System.out.println("Securities file = " + security);
- System.out.println("Portfolios file = " + portfolio);
-
- ObjectStore.initialize(host, null);
-
- Database db;
-
- try {
- db = Database.open(dbpath, ObjectStore.OPEN_UPDATE);
- db.destroy();
- } catch (DatabaseNotFoundException e) {
- }
-
- db = Database.create(dbpath, ObjectStore.ALL_READ | ObjectStore.ALL_WRITE);
- Transaction t = Transaction.begin(ObjectStore.UPDATE);
-
- Security.load(security, db);
- Portfolio.load(portfolio, db);
-
- t.commit();
-
- db.close();
- }
- }
-
-