|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DB
DB
defines the interface for a Torque database
adapter. Support for new databases is added by implementing this
interface. A couple of default settings is provided by
subclassing AbstractDBAdapter
. The new database adapter
and its corresponding JDBC driver need to be registered in the service
configuration file.
The Torque database adapters exist to present a uniform interface to database access across all available databases. Once the necessary adapters have been written and configured, transparent swapping of databases is theoretically supported with zero code changes and minimal configuration file modifications. All database adapters need to be thread safe, as they are instantiated only once fore a given configured database and may be accessed simultaneously from several threads.
Torque uses the driver class name to find the right adapter.
A JDBC driver corresponding to your adapter must be added to the properties
file, using the fully-qualified class name of the driver. If no driver is
specified for your database, driver.default
is used.
#### MySQL MM Driver database.default.driver=org.gjt.mm.mysql.Driver database.default.url=jdbc:mysql://localhost/DATABASENAME
Field Summary | |
---|---|
static java.lang.String |
ADAPTER_KEY
Key for the configuration which contains database adapters. |
static java.lang.String |
DRIVER_KEY
Key for the configuration which contains database drivers. |
static int |
LIMIT_STYLE_DB2
Deprecated. This should not be exposed to the outside |
static int |
LIMIT_STYLE_MYSQL
Deprecated. This should not be exposed to the outside |
static int |
LIMIT_STYLE_NONE
Deprecated. This should not be exposed to the outside |
static int |
LIMIT_STYLE_ORACLE
Deprecated. This should not be exposed to the outside |
static int |
LIMIT_STYLE_POSTGRES
Deprecated. This should not be exposed to the outside |
static int |
LIMIT_STYLE_SYBASE
Deprecated. This should not be exposed to the outside |
Fields inherited from interface org.apache.torque.adapter.IDMethod |
---|
AUTO_INCREMENT, ID_BROKER, NATIVE, NO_ID_METHOD, SEQUENCE |
Method Summary | |
---|---|
boolean |
escapeText()
Whether backslashes (\) should be escaped in explicit SQL strings. |
void |
generateLimits(Query query,
int offset,
int limit)
This method is used to generate the database specific query extension to limit the number of record returned. |
java.lang.String |
getBooleanString(java.lang.Boolean b)
This method is used to format a boolean string. |
java.lang.String |
getDateString(java.util.Date date)
This method is used to format any date string. |
java.lang.Class |
getFunctionClass(FunctionEnum function)
Return the class which implements the SQLFunction interface for the specified function. |
java.lang.String |
getIDMethodSQL(java.lang.Object obj)
Returns SQL used to get the most recently inserted primary key. |
java.lang.String |
getIDMethodType()
Returns the constant from the IDMethod interface denoting which
type of primary key generation method this type of RDBMS uses. |
int |
getLimitStyle()
Deprecated. This should not be exposed to the outside |
char |
getStringDelimiter()
Returns the character used to indicate the beginning and end of a piece of text used in a SQL statement (generally a single quote). |
java.lang.String |
ignoreCase(java.lang.String in)
Modifies a SQL snippet such that its case is ignored by the database. |
java.lang.String |
ignoreCaseInOrderBy(java.lang.String in)
This method is used to ignore case in an ORDER BY clause. |
void |
lockTable(java.sql.Connection con,
java.lang.String table)
Locks the specified table. |
boolean |
supportsNativeLimit()
This method is used to check whether the database natively supports limiting the size of the resultset. |
boolean |
supportsNativeOffset()
This method is used to check whether the database natively supports returning results starting at an offset position other than 0. |
java.lang.String |
toUpperCase(java.lang.String in)
This method is used to ignore case. |
void |
unlockTable(java.sql.Connection con,
java.lang.String table)
Unlocks the specified table. |
boolean |
useEscapeClauseForLike()
Whether an escape clause in like should be used. |
boolean |
useIlike()
Whether ILIKE should be used for case insensitive like clauses. |
Field Detail |
---|
static final int LIMIT_STYLE_NONE
static final int LIMIT_STYLE_POSTGRES
SELECT ... LIMIT , [<offset>]
static final int LIMIT_STYLE_MYSQL
SELECT ... LIMIT [, ] <offset>
static final int LIMIT_STYLE_SYBASE
SET ROWCOUNT <offset> SELECT ... SET ROWCOUNT 0
static final int LIMIT_STYLE_ORACLE
SELECT ... WHERE ... AND ROWNUM <
static final int LIMIT_STYLE_DB2
SELECT ... WHERE ... AND ROW_NUMBER() OVER() <
static final java.lang.String ADAPTER_KEY
static final java.lang.String DRIVER_KEY
Method Detail |
---|
java.lang.String toUpperCase(java.lang.String in)
in
- The string to transform to upper case.
char getStringDelimiter()
java.lang.String getIDMethodType()
IDMethod
interface denoting which
type of primary key generation method this type of RDBMS uses.
java.lang.String getIDMethodSQL(java.lang.Object obj)
null
.
obj
- Information used for key generation.
void lockTable(java.sql.Connection con, java.lang.String table) throws java.sql.SQLException
con
- The JDBC connection to use.table
- The name of the table to lock.
java.sql.SQLException
- No Statement could be created or executed.void unlockTable(java.sql.Connection con, java.lang.String table) throws java.sql.SQLException
con
- The JDBC connection to use.table
- The name of the table to unlock.
java.sql.SQLException
- No Statement could be created or executed.java.lang.String ignoreCase(java.lang.String in)
in
- The SQL snippet whose case to ignore.
java.lang.String ignoreCaseInOrderBy(java.lang.String in)
in
- The string whose case to ignore.
boolean supportsNativeLimit()
boolean supportsNativeOffset()
void generateLimits(Query query, int offset, int limit) throws TorqueException
query
- The query to modifyoffset
- the offset Valuelimit
- the limit Value
TorqueException
- if any error occurs when building the queryboolean escapeText()
int getLimitStyle()
java.lang.String getDateString(java.util.Date date)
date
- the Date to format
java.lang.String getBooleanString(java.lang.Boolean b)
b
- the Boolean to format
boolean useIlike()
boolean useEscapeClauseForLike()
java.lang.Class getFunctionClass(FunctionEnum function)
function
- The function to get the class for.
SQLFunction
,
AbstractFunction
,
Aggregate
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |