|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jminor.common.db.AbstractDatabase
public abstract class AbstractDatabase
A default abstract implementation of the Database interface.
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 | |
---|---|
AbstractDatabase(String databaseType)
Instantiates a new AbstractDatabase using host/port/sid/embedded settings specified by system properties |
|
AbstractDatabase(String databaseType,
String host)
Instantiates a new AbstractDatabase using port/sid/embedded settings specified by system properties |
|
AbstractDatabase(String databaseType,
String host,
String port)
Instantiates a new AbstractDatabase using sid/embedded settings specified by system properties |
|
AbstractDatabase(String databaseType,
String host,
String port,
String sid)
Instantiates a new AbstractDatabase using the embedded settings specified by the system property |
|
AbstractDatabase(String databaseType,
String host,
String port,
String sid,
boolean embedded)
Instantiates a new AbstractDatabase |
Method Summary | |
---|---|
Properties |
addConnectionProperties(Properties properties)
Adds any dbms specific connection properties to the given properties map |
Connection |
createConnection(User user)
Creates a connection for the given user. |
String |
getAuthenticationInfo(Properties connectionProperties)
Returns a string containing authentication info to append to the connection URL, base on the values found in connectionProperties . |
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 |
getDatabaseType()
|
String |
getErrorMessage(SQLException exception)
Returns a user friendly error message for the given exception, otherwise simply return the message from exception |
String |
getHost()
|
protected int |
getLoginTimeout()
|
String |
getPort()
|
String |
getSequenceSQL(String sequenceName)
|
String |
getSid()
|
boolean |
isEmbedded()
|
void |
shutdownEmbedded(Properties connectionProperties)
This should shutdown the database in case it is an embedded one and if that is applicable, such as for Derby. |
boolean |
supportsIsValid()
|
boolean |
supportsNowait()
Returns true if the dbms supports the select for update NOWAIT option |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.jminor.common.db.Database |
---|
getAutoIncrementValueSQL, getURL, loadDriver |
Constructor Detail |
---|
public AbstractDatabase(String databaseType)
databaseType
- a string identifying the database typeDatabase.DATABASE_HOST
,
Database.DATABASE_PORT
,
Database.DATABASE_SID
,
Database.DATABASE_EMBEDDED
public AbstractDatabase(String databaseType, String host)
databaseType
- a string identifying the database typehost
- the database host name or path to the database files in case of an embedded databaseDatabase.DATABASE_PORT
,
Database.DATABASE_SID
,
Database.DATABASE_EMBEDDED
public AbstractDatabase(String databaseType, String host, String port)
databaseType
- a string identifying the database typehost
- the database host name or path to the database files in case of an embedded databaseport
- the database server portDatabase.DATABASE_SID
,
Database.DATABASE_EMBEDDED
public AbstractDatabase(String databaseType, String host, String port, String sid)
databaseType
- a string identifying the database typehost
- the database host name or path to the database files in case of an embedded databaseport
- the database server portsid
- the service identifierDatabase.DATABASE_EMBEDDED
public AbstractDatabase(String databaseType, String host, String port, String sid, boolean embedded)
databaseType
- a string identifying the database typehost
- the database host name or path to the database files in case of an embedded databaseport
- the database server portsid
- the service identifierembedded
- true if the database is embeddedMethod Detail |
---|
public final String getDatabaseType()
getDatabaseType
in interface Database
public final String getHost()
getHost
in interface Database
public final String getPort()
getPort
in interface Database
public final String getSid()
getSid
in interface Database
public final boolean isEmbedded()
isEmbedded
in interface Database
public final Connection createConnection(User user) throws ClassNotFoundException, SQLException
createConnection
in interface Database
user
- the user for which to create a connection
ClassNotFoundException
- in case the driver class was not on the classpath
SQLException
- in case of a connection errorpublic boolean supportsNowait()
supportsNowait
in interface Database
public boolean supportsIsValid()
supportsIsValid
in interface Database
public String getCheckConnectionQuery()
getCheckConnectionQuery
in interface Database
Database.supportsIsValid()
public void shutdownEmbedded(Properties connectionProperties)
shutdownEmbedded
in interface Database
connectionProperties
- the connection propertiespublic String getSequenceSQL(String sequenceName)
getSequenceSQL
in interface Database
sequenceName
- the name of the sequence
public String getAuthenticationInfo(Properties connectionProperties)
connectionProperties
.
This default implementation returns the following assuming that connectionProperties
contains values for both "user" and "password" keys:
user=scott;password=tiger
getAuthenticationInfo
in interface Database
connectionProperties
- the connection properties
public String getErrorMessage(SQLException exception)
exception
getErrorMessage
in interface Database
exception
- the underlying SQLException
public Properties addConnectionProperties(Properties properties)
addConnectionProperties
in interface Database
properties
- the properties map to add to
protected int getLoginTimeout()
Database.DEFAULT_LOGIN_TIMEOUT
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |