org.jminor.common.db.dbms
Class OracleDatabase

java.lang.Object
  extended by org.jminor.common.db.AbstractDatabase
      extended by org.jminor.common.db.dbms.OracleDatabase
All Implemented Interfaces:
Database

public final class OracleDatabase
extends AbstractDatabase

A Database implementation based on the Oracle database.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jminor.common.db.Database
Database.Statistics
 
Field Summary
 
Fields inherited from interface org.jminor.common.db.Database
DATABASE_EMBEDDED, DATABASE_HOST, DATABASE_IMPLEMENTATION_CLASS, DATABASE_POOL_STATISTICS, DATABASE_PORT, DATABASE_SID, DATABASE_TYPE, DEFAULT_LOGIN_TIMEOUT, DERBY, H2, HSQL, MYSQL, ORACLE, PASSWORD_PROPERTY, POSTGRESQL, SQLSERVER, USER_PROPERTY
 
Constructor Summary
OracleDatabase()
          Instantiates a new OracleDatabase.
OracleDatabase(String host, String port, String sid)
          Instantiates a new OracleDatabase.
 
Method Summary
 String getAutoIncrementValueSQL(String idSource)
          Returns a query string for retrieving the last automatically generated id from the given id source
 String getCheckConnectionQuery()
          Returns a query to use when checking if the connection is valid, this is used in cases where the dbms does not support the isValid() call.
 String getErrorMessage(SQLException exception)
          Returns a user friendly error message for the given exception, otherwise simply return the message from exception
 String getSequenceSQL(String sequenceName)
          
 String getURL(Properties connectionProperties)
          
 void loadDriver()
          Loads the database driver
 boolean supportsIsValid()
          
 
Methods inherited from class org.jminor.common.db.AbstractDatabase
addConnectionProperties, createConnection, getAuthenticationInfo, getDatabaseType, getHost, getLoginTimeout, getPort, getSid, isEmbedded, shutdownEmbedded, supportsNowait
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDatabase

public OracleDatabase()
Instantiates a new OracleDatabase.


OracleDatabase

public OracleDatabase(String host,
                      String port,
                      String sid)
Instantiates a new OracleDatabase.

Parameters:
host - the host name
port - the port number
sid - the service identifier
Method Detail

loadDriver

public void loadDriver()
                throws ClassNotFoundException
Loads the database driver

Throws:
ClassNotFoundException - in case the driver class in not found

getAutoIncrementValueSQL

public String getAutoIncrementValueSQL(String idSource)
Returns a query string for retrieving the last automatically generated id from the given id source

Parameters:
idSource - the source for the id, for example a sequence name or in the case of Derby, the name of the table
Returns:
a query string for retrieving the last auto-increment value from idSource

getSequenceSQL

public String getSequenceSQL(String sequenceName)

Specified by:
getSequenceSQL in interface Database
Overrides:
getSequenceSQL in class AbstractDatabase
Parameters:
sequenceName - the name of the sequence
Returns:
a query for selecting the next value from the given sequence

getURL

public String getURL(Properties connectionProperties)

Parameters:
connectionProperties - the connection properties, used primarily to provide embedded databases with user info for authentication purposes
Returns:
the database url of the active database, based on system properties

supportsIsValid

public boolean supportsIsValid()
Description copied from class: AbstractDatabase

Specified by:
supportsIsValid in interface Database
Overrides:
supportsIsValid in class AbstractDatabase
Returns:
false

getCheckConnectionQuery

public String getCheckConnectionQuery()
Returns a query to use when checking if the connection is valid, this is used in cases where the dbms does not support the isValid() call. Returning null is safe if isValid() is supported.

Specified by:
getCheckConnectionQuery in interface Database
Overrides:
getCheckConnectionQuery in class AbstractDatabase
Returns:
a check connection query
See Also:
Database.supportsIsValid()

getErrorMessage

public String getErrorMessage(SQLException exception)
Returns a user friendly error message for the given exception, otherwise simply return the message from exception

Specified by:
getErrorMessage in interface Database
Overrides:
getErrorMessage in class AbstractDatabase
Parameters:
exception - the underlying SQLException
Returns:
the message assigned to the given exception