|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Database
Defines DBMS specific functionality as well as basic database configuration settings.
Nested Class Summary | |
---|---|
static interface |
Database.Statistics
Encapsulates basic database usage statistics. |
Field Summary | |
---|---|
static String |
DATABASE_EMBEDDED
Specifies whether or not the database should be run in embedded mode, if applicable Values: "true"/"false" Default: "false" |
static String |
DATABASE_HOST
Specifies the machine hosting the database, in the case of embedded databases this specifies the name of the database |
static String |
DATABASE_IMPLEMENTATION_CLASS
Specifies the Database implementation class to use in case of a dbms that is not directly supported |
static String |
DATABASE_POOL_STATISTICS
Specifies whether or not connection pools should collect fine grained performance/usage statistics by default, true or false |
static String |
DATABASE_PORT
Specifies the database port |
static String |
DATABASE_SID
Specifies the database sid (used for dbname for MySQL, SQLServer and Derby server connections) |
static String |
DATABASE_TYPE
Specifies the database type |
static int |
DEFAULT_LOGIN_TIMEOUT
The default connection login timeout |
static String |
DERBY
The constant used to denote the Derby database type |
static String |
H2
The constant used to denote the H2 database type |
static String |
HSQL
The constant used to denote the HSQL database type |
static String |
MYSQL
The constant used to denote the MySQL database type |
static String |
ORACLE
The constant used to denote the Oracle database type |
static String |
PASSWORD_PROPERTY
The constant used to denote the password value in the connection properties |
static String |
POSTGRESQL
The constant used to denote the PostgreSQL database type |
static String |
SQLSERVER
The constant used to denote the Microsoft SQL Server database type |
static String |
USER_PROPERTY
The constant used to denote the username value in the connection properties |
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)
In the case of embedded databases the user login info can be appended to the connection url, this method should return that string in case the dbms requires it and connectionProperties contains
the username and password info, otherwise it should be safe to return null. |
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 |
getDatabaseType()
|
String |
getErrorMessage(SQLException exception)
Returns a user friendly error message for the given exception, otherwise simply return the message from exception |
String |
getHost()
|
String |
getPort()
|
String |
getSequenceSQL(String sequenceName)
|
String |
getSid()
|
String |
getURL(Properties connectionProperties)
|
boolean |
isEmbedded()
|
void |
loadDriver()
Loads the database driver |
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 |
Field Detail |
---|
static final String DATABASE_TYPE
DERBY
,
HSQL
,
H2
,
MYSQL
,
ORACLE
,
POSTGRESQL
,
SQLSERVER
,
Constant Field Valuesstatic final String DATABASE_HOST
static final String DATABASE_SID
static final String DATABASE_PORT
static final String DATABASE_EMBEDDED
static final String DATABASE_IMPLEMENTATION_CLASS
Database
,
Constant Field Valuesstatic final String DATABASE_POOL_STATISTICS
static final String ORACLE
DATABASE_TYPE
,
Constant Field Valuesstatic final String MYSQL
DATABASE_TYPE
,
Constant Field Valuesstatic final String POSTGRESQL
DATABASE_TYPE
,
Constant Field Valuesstatic final String SQLSERVER
DATABASE_TYPE
,
Constant Field Valuesstatic final String DERBY
DATABASE_TYPE
,
Constant Field Valuesstatic final String H2
DATABASE_TYPE
,
Constant Field Valuesstatic final String HSQL
DATABASE_TYPE
,
Constant Field Valuesstatic final String USER_PROPERTY
static final String PASSWORD_PROPERTY
static final int DEFAULT_LOGIN_TIMEOUT
DriverManager.setLoginTimeout(int)
,
Constant Field ValuesMethod Detail |
---|
void loadDriver() throws ClassNotFoundException
ClassNotFoundException
- in case the driver class in not foundString getDatabaseType()
String getHost()
String getPort()
String getSid()
boolean isEmbedded()
String getAutoIncrementValueSQL(String idSource)
idSource
- the source for the id, for example a sequence name or in the case of Derby, the name of the table
String getSequenceSQL(String sequenceName)
sequenceName
- the name of the sequence
String getURL(Properties connectionProperties)
connectionProperties
- the connection properties, used primarily to provide
embedded databases with user info for authentication purposes
String getAuthenticationInfo(Properties connectionProperties)
connectionProperties
contains
the username and password info, otherwise it should be safe to return null.
This method is usually used in getURL()
and onDisconnect()
.
connectionProperties
- the connection properties
void shutdownEmbedded(Properties connectionProperties)
connectionProperties
- the connection propertiesboolean supportsIsValid()
boolean supportsNowait()
String getCheckConnectionQuery()
supportsIsValid()
String getErrorMessage(SQLException exception)
exception
exception
- the underlying SQLException
Properties addConnectionProperties(Properties properties)
properties
- the properties map to add to
Connection createConnection(User user) throws ClassNotFoundException, SQLException
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 error
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |