com.lightdev.app.trec.server
Class EmbeddedDerbyAdapter

java.lang.Object
  extended by com.lightdev.lib.sam.JDBCAdapter
      extended by com.lightdev.app.trec.server.EmbeddedDerbyAdapter

public class EmbeddedDerbyAdapter
extends JDBCAdapter

Adapter to an embedded Derby database implementation of the SAM framework

Version:
2, 01.01.2006
Author:
Ulrich Hilger, Light Development, http://www.lightdev.com, info@lightdev.com, published under the terms and conditions of the BSD License, for details see file license.txt in the distribution package of this software

Field Summary
 
Fields inherited from class com.lightdev.lib.sam.JDBCAdapter
RB_KEY_DB_DRIVER_NAME, RB_KEY_DB_NAME, RB_KEY_DB_PREFIX, RB_KEY_DB_PW, RB_KEY_DB_SERVER_NAME, RB_KEY_DB_USER_NAME
 
Constructor Summary
EmbeddedDerbyAdapter(String baseDir)
          create a new instance of a EmbeddedDerbyAdapter object
 
Method Summary
 void backup(String backupDirectory)
          backup the SAM database of this adapter to a given backup directory.
 void destroy()
           
 Vector getAvailableBackups()
           
 Connection getConnection()
          get a connection to the database
 String getConnectString()
          assemble a Derby connect string such as jdbc:derby:url_to_db/db_name;user=name;password=pw
 void restore(String backupDirectory)
          restore the SAM database of this adapter from a given backup directory.
 boolean supportsTransactions()
          determine whether or not the database can handle transactions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmbeddedDerbyAdapter

public EmbeddedDerbyAdapter(String baseDir)
create a new instance of a EmbeddedDerbyAdapter object

Parameters:
baseDir - the base directory in which the database is located
Method Detail

destroy

public void destroy()
Specified by:
destroy in class JDBCAdapter

backup

public void backup(String backupDirectory)
            throws Exception
backup the SAM database of this adapter to a given backup directory. This will lock the database for writing and freezes write access during backup. Read access reamins possible.

Parameters:
backupDirectory - the diretory to backup the database to; this adapter builds a backup directory using scheme [base dir]/sambackup/[backupDirectory].
Throws:
Exception

restore

public void restore(String backupDirectory)
             throws SQLException
restore the SAM database of this adapter from a given backup directory. This will close the current connection to the database. If a database with the same name exists in the SAM DB location, the system will delete the database, copy it from the backup location, and then restart it.

Parameters:
backupDirectory - the diretory to restore the database from; this adapter builds a directory using scheme [base dir]/sambackup/[backupDirectory] to restore from.
Throws:
SQLException

getAvailableBackups

public Vector getAvailableBackups()

getConnection

public Connection getConnection()
                         throws Exception
get a connection to the database

Specified by:
getConnection in class JDBCAdapter
Returns:
the database connection
Throws:
SQLException - is something goes wrong with establishing the connection
Exception

supportsTransactions

public boolean supportsTransactions()
determine whether or not the database can handle transactions

Specified by:
supportsTransactions in class JDBCAdapter
Returns:
true, if transactions are supported, false if not

getConnectString

public String getConnectString()
assemble a Derby connect string such as jdbc:derby:url_to_db/db_name;user=name;password=pw

Specified by:
getConnectString in class JDBCAdapter
Returns:
the connect string