org.jminor.common.db
Class Databases

java.lang.Object
  extended by org.jminor.common.db.Databases

public final class Databases
extends Object

Provides Database implementations based on system settings.

See Also:
Database.DATABASE_IMPLEMENTATION_CLASS, Database.DATABASE_TYPE

Nested Class Summary
static class Databases.DatabaseStatistics
          A default DatabaseStatistics implementation.
static class Databases.QueryCounter
          A class for counting query types, providing avarages over time
 
Field Summary
static ResultPacker<Integer> INT_PACKER
          A result packer for fetching integers from an result set containing a single integer column
static Databases.QueryCounter QUERY_COUNTER
          A synchronized query counter
static ResultPacker<String> STRING_PACKER
          A result packer for fetching strings from an result set containing a single string column
 
Method Summary
static void addOperation(DatabaseConnection.Operation operation)
          Adds the given Operation to this repository
static Database createInstance()
           
static Database.Statistics getDatabaseStatistics()
           
static String getDatabaseType()
           
static DatabaseConnection.Function getFunction(String functionID)
           
static DatabaseConnection.Procedure getProcedure(String procedureID)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUERY_COUNTER

public static final Databases.QueryCounter QUERY_COUNTER
A synchronized query counter


INT_PACKER

public static final ResultPacker<Integer> INT_PACKER
A result packer for fetching integers from an result set containing a single integer column


STRING_PACKER

public static final ResultPacker<String> STRING_PACKER
A result packer for fetching strings from an result set containing a single string column

Method Detail

createInstance

public static Database createInstance()
Returns:
a new Database instance based on runtime properties
Throws:
RuntimeException - if an unrecognized database type is specified
See Also:
Database.DATABASE_TYPE, Database.DATABASE_IMPLEMENTATION_CLASS

getDatabaseType

public static String getDatabaseType()
Returns:
the database type string as specified by the DATABASE_TYPE system property
See Also:
Database.DATABASE_TYPE

addOperation

public static void addOperation(DatabaseConnection.Operation operation)
Adds the given Operation to this repository

Parameters:
operation - the operation to add
Throws:
RuntimeException - in case an operation with the same ID has already been added

getProcedure

public static DatabaseConnection.Procedure getProcedure(String procedureID)
Parameters:
procedureID - the procedure ID
Returns:
the procedure
Throws:
RuntimeException - in case the procedure is not found

getFunction

public static DatabaseConnection.Function getFunction(String functionID)
Parameters:
functionID - the function ID
Returns:
the function
Throws:
RuntimeException - in case the function is not found

getDatabaseStatistics

public static Database.Statistics getDatabaseStatistics()
Returns:
a DatabaseStatistics object containing the most recent statistics from the underlying database