dk.netarkivet.harvester.datamodel
Class DBSpecifics

java.lang.Object
  extended by dk.netarkivet.common.utils.SettingsFactory<DBSpecifics>
      extended by dk.netarkivet.harvester.datamodel.DBSpecifics
Direct Known Subclasses:
DerbySpecifics, MySQLSpecifics

public abstract class DBSpecifics
extends SettingsFactory<DBSpecifics>

Abstract collection of DB methods that are not standard SQL. This class is a singleton class whose actual implementation is provided by a subclass as determined by the DB_SPECIFICS_CLASS setting.


Constructor Summary
DBSpecifics()
           
 
Method Summary
abstract  void backupDatabase(java.io.File backupDir)
          Backup the database.
abstract  void dropJobConfigsTmpTable(java.sql.Connection c, java.lang.String tableName)
          Dispose of a temporary table gotten with getTemporaryTable.
abstract  java.lang.String getDriverClassName()
          Get the name of the JDBC driver class that handles interfacing to this server.
static DBSpecifics getInstance()
          Get the singleton instance of the DBSpecifics implementation class
abstract  java.lang.String getJobConfigsTmpTable(java.sql.Connection c)
          Get a temporary table for short-time use.
abstract  void shutdownDatabase()
          Shutdown the database system, if running embeddedly.
 void updateTable(java.lang.String tableName, int toVersion)
          Update a table to a newer version, if necessary.
 
Methods inherited from class dk.netarkivet.common.utils.SettingsFactory
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBSpecifics

public DBSpecifics()
Method Detail

getInstance

public static DBSpecifics getInstance()
Get the singleton instance of the DBSpecifics implementation class

Returns:
An instance of DBSpecifics with implementations for a given DB.

shutdownDatabase

public abstract void shutdownDatabase()
Shutdown the database system, if running embeddedly. Otherwise, this is ignored. Will log a warning on errors, but otherwise ignore them.


getJobConfigsTmpTable

public abstract java.lang.String getJobConfigsTmpTable(java.sql.Connection c)
                                                throws java.sql.SQLException
Get a temporary table for short-time use. The table should be disposed of with dropTemporaryTable. The table has two columns domain_name varchar(Constants.MAX_NAME_SIZE) + config_name varchar(Constants.MAX_NAME_SIZE) All rows in the table must be deleted at commit or rollback.

Parameters:
c - The DB connection to use.
Returns:
The name of the created table
Throws:
java.sql.SQLException - if there is a problem getting the table.

dropJobConfigsTmpTable

public abstract void dropJobConfigsTmpTable(java.sql.Connection c,
                                            java.lang.String tableName)
Dispose of a temporary table gotten with getTemporaryTable. This can be expected to be called from within a finally clause, so it mustn't throw exceptions.

Parameters:
c - The DB connection to use.
tableName - The name of the temporarily created table.

backupDatabase

public abstract void backupDatabase(java.io.File backupDir)
                             throws java.sql.SQLException
Backup the database. For server-based databases, where the administrator is expected to perform the backups, this method should do nothing. This method gets called within one hour of the hour-of-day indicated by the DB_BACKUP_INIT_HOUR settings.

Parameters:
backupDir - Directory to which the database should be backed up
Throws:
java.sql.SQLException
PermissionDenied - if the directory cannot be created.

getDriverClassName

public abstract java.lang.String getDriverClassName()
Get the name of the JDBC driver class that handles interfacing to this server.

Returns:
The name of a JDBC driver class

updateTable

public void updateTable(java.lang.String tableName,
                        int toVersion)
Update a table to a newer version, if necessary. This will check the schemaversions table to see the current version and perform a table-specific update if required.

Parameters:
tableName - The table to update
toVersion - The version to update the table to.