1 24 25 package com.mckoi.tools; 26 27 import java.io.*; 28 import com.mckoi.database.*; 29 import com.mckoi.database.control.*; 30 import com.mckoi.util.CommandLine; 31 import com.mckoi.debug.*; 32 33 39 40 public class DataFileConvertTool { 41 42 45 private static void printSyntax() { 46 System.out.println("DataFileConvertTool -path [data files path] " + 47 "-u [admin username] -p [admin password]"); 48 } 49 50 53 public static void main(String [] args) { 54 CommandLine cl = new CommandLine(args); 55 56 String path = cl.switchArgument("-path"); 57 String admin_username = cl.switchArgument("-u"); 58 String admin_password = cl.switchArgument("-p"); 59 60 if (path == null) { 61 printSyntax(); 62 System.out.println("Error: -path not found on command line."); 63 System.exit(-1); 64 } 65 if (admin_username == null) { 66 printSyntax(); 67 System.out.println("Error: -u [username] not found on command line."); 68 System.exit(-1); 69 } 70 if (admin_password == null) { 71 printSyntax(); 72 System.out.println("Error: -p [password] not found on command line."); 73 System.exit(-1); 74 } 75 76 DatabaseSystem system = new DatabaseSystem(); 77 78 DefaultDBConfig config = new DefaultDBConfig(); 80 config.setDatabasePath(path); 81 config.setMinimumDebugLevel(Integer.MAX_VALUE); 82 83 system.setDebugLevel(Integer.MAX_VALUE); 85 86 89 system.init(config); 92 93 96 Database database = new Database(system, "DefaultDatabase"); 99 100 boolean success = false; 101 try { 102 success = database.convertToCurrent(System.out, admin_username); 104 } 105 catch (IOException e) { 106 System.out.println("IO Error: " + e.getMessage()); 107 e.printStackTrace(System.out); 108 } 109 110 if (success) { 111 System.out.println("-- Convert Successful --"); 112 } 113 else { 114 System.out.println("-- Convert Failed --"); 115 } 116 117 database.startShutDownThread(); 119 database.waitUntilShutdown(); 120 121 } 122 123 } 124 | Popular Tags |