1 package com.genimen.djeneric.test; 2 3 import junit.framework.Assert; 4 5 import com.genimen.djeneric.util.DjLogger; 6 7 10 public class StartHypersonic 11 { 12 public static String port = "9876"; 13 public static DbRunner runner = null; 14 15 public static void main(String args[]) 16 { 17 try 18 { 19 String dbFile = Util.resource2FileName(StartHypersonic.class.getResource("db"), "test"); 20 21 System.out.println("Starting Hypersonic Database " + dbFile); 22 runner = new DbRunner(dbFile); 23 runner.start(); 24 25 29 try 30 { 31 Thread.sleep(2000); 32 } 33 catch (InterruptedException e) 34 { 35 DjLogger.log(e); 36 } 37 } 38 catch (Exception x) 39 { 40 DjLogger.log(x); 41 Assert.assertTrue(false); 42 } 43 } 44 45 public static boolean isRunning() 46 { 47 if (runner == null) return false; 48 return runner.isRunning(); 49 } 50 } 51 52 class DbRunner extends Thread 53 { 54 String _dbloc; 55 boolean _isRunning = false; 56 57 public DbRunner(String dbloc) 58 { 59 _dbloc = dbloc; 60 } 61 62 public void run() 63 { 64 _isRunning = true; 65 org.hsqldb.Server.main(new String []{"-no_system_exit", "true", "-port", StartHypersonic.port, "-database", _dbloc}); 66 _isRunning = false; 67 } 68 69 public boolean isRunning() 70 { 71 return _isRunning; 72 } 73 74 } | Popular Tags |