X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fpersistence%2FDatabaseStarter.java;fp=support%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fpersistence%2FDatabaseStarter.java;h=0000000000000000000000000000000000000000;hb=32a62ca2c752e33a7873ac868a7a1f289caedcd4;hp=c0bdcc2f97b4180e02290ce0de8058732c90284b;hpb=d2bdf4e813c6a3964958c87b2ce56eaadf8a1f0a;p=utils diff --git a/support/src/test/java/org/wamblee/persistence/DatabaseStarter.java b/support/src/test/java/org/wamblee/persistence/DatabaseStarter.java deleted file mode 100644 index c0bdcc2f..00000000 --- a/support/src/test/java/org/wamblee/persistence/DatabaseStarter.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2005 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wamblee.persistence; - - -/** - * This class is used for starting the database from ant. - */ -public class DatabaseStarter { - - /** - * Database class which encapsulates management of the database. - */ - private Class _databaseClass; - - /** - * Execution as a main program. Commandline - * - *
-     * 
-     *    DatabaseStarter <databaseClassName>
-     *  
-     * 
- * - * where the database class name must be the name of a concrete subclass of - * {@link Database}. - * - * @param args - */ - public static void main( String[] args ) throws Exception { - String clazz = args[0]; - try { - new DatabaseStarter( Class.forName( clazz ) ).start( ); - } catch ( Exception e ) { - e.printStackTrace( ); - System.out - .println( "\nUsage: ant -Ddatabase=Derby|Hypersonic startdb" ); - } - } - - /** - * Constructs the database starter. - * - * @param aClassName - * Classname of the database class to use. - * @throws Exception - */ - public DatabaseStarter( Class aClass ) throws Exception { - if ( !Database.class.isAssignableFrom( aClass ) ) { - throw new IllegalArgumentException( "Class '" - + aClass.getName( ) - + "' is not a subclass of Database" ); - } - _databaseClass = aClass; - } - - /** - * Constructs a database starter with the derby database. - * - * @throws Exception - */ - public DatabaseStarter( ) throws Exception { - this( DerbyDatabase.class ); - } - - /** - * Starts the database. - * - * @throws Exception - */ - public void start( ) throws Exception { - Database lDatabase = (Database) _databaseClass.newInstance( ); - lDatabase.start( ); - System.out.println( "Database has been started. " ); - System.out.println( ); - System.out.println("======================================================="); - System.out.println( "Connection details:" ); - System.out.println( " Driver class: " - + lDatabase.getDriverClassName( ) ); - System.out.println( " JDBC URL: " - + lDatabase.getExternalJdbcUrl( ) ); - System.out.println( " username: '" + lDatabase.getUsername( ) - + "'" ); - System.out.println( " password: '" + lDatabase.getPassword( ) - + "'" ); - System.out.println( "Interrupt the program to stop the database." ); - System.out.println("======================================================="); - System.out.println("You must now populate the database with a schema. Use 'ant help' for information."); - for ( ;; ) { - Thread.sleep( 1000 ); - } - } -}