Hello Fred!

I am database vendor independent components developer. I would like to 
advise use a most common behaviour of any database as by default 
configured. This is about property "jdbc.get_column_name=false". 
Backward compatibility is important of course, but IMHO this could make 
life more easier

I found hsqldb perfect for our test system. I use ANT to start database, 
execute tests and shut down database while execute project build. I use 
my own shutdowner. I think that this class (or something else with same 
functionality) could be part of hsqldb distribution.

Ansis

import java.sql.Connection ;
import java.sql.DriverManager ;
import java.sql.Statement ;
import java.sql.SQLException ;
import java.util.Properties ;

/**
  * Shut down hsqldb database server
  */
public class Shutdown {
   private String driver ;
   private String url ;
   private String user ;
   private String password ;

   public Shutdown (Properties props) {
     driver   = props.getProperty ("driver", "org.hsqldb.jdbcDriver") ;
     url      = props.getProperty ("url", "jdbc:hsqldb:hsql://localhost") ;
     user     = props.getProperty ("user", "sa") ;
     password = props.getProperty ("password", "") ;
   }

   public void shutdown () {
     try {
       Class.forName (driver).newInstance () ;
       Connection conn = DriverManager.getConnection (url, user, password) ;

       Statement stmt = conn.createStatement () ;
       System.out.println ("Shutdown hsqldb database...") ;
       stmt.execute ("shutdown") ;
       System.out.println ("Shutdown done") ;

       try {
         stmt.close () ;
         conn.close () ;
       } catch (SQLException ignore) {}

     } catch (Exception e) {
       e.printStackTrace () ;
     }
   }

   public static void main (String [] args) {
     Properties props = new Properties () ;

     for (int i = 0; i < args.length; i++) {
       String key = args [i] ;

       if (key.equals ("-?") || key.equals ("/?")) {
         printHelp () ;
         i = args.length ;
       }

       if (key.charAt (0) == '-') {
         props.put (key.substring (1), args [i + 1]) ;
         i++ ;
       }
     }

     new Shutdown (props).shutdown () ;
   }

   private static void printHelp () {
     System.out.println (
         "Shut down hsqldb database server\n" +
         "Usage: java ShutDown [-options]\n" +
         "where options include:\n" +
         "    -driver <classname>  name of the driver class\n" +
         "    -url <name>          database jdbc url\n" +
         "    -user <name>         username used for connection\n" +
         "    -password <name>     password for this user\n") ;
   }

} // End of class ShutDown



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
hsqldb-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hsqldb-developers

Reply via email to