|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Adapter
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. *
Field Summary | |
---|---|
static String |
ADAPTER_KEY
Key for the configuration which contains database adapters. |
static String |
AUTODETECT_ADAPTER
Special adapter for auto-detection. |
static String |
DRIVER_KEY
Key for the configuration which contains database drivers. |
Method Summary | |
---|---|
boolean |
escapeText()
Determines whether backslashes (\) should be escaped in explicit SQL strings. |
void |
generateLimits(Query query,
long offset,
int limit)
This method is used to generate the database specific query extension to limit the number of record returned. |
String |
getIDMethodSQL(Object obj)
Returns SQL used to get the most recently inserted primary key. |
IDMethod |
getIDMethodType()
Returns the constant from the IDMethod interface denoting which
type of primary key generation method this type of RDBMS uses. |
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). |
String |
ignoreCase(String in)
Wraps the input string in a database function to change it to a case-insensitive representation. |
String |
ignoreCaseInOrderBy(String in)
This method is used to ignore case in an ORDER BY clause. |
void |
lockTable(Connection con,
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. |
TorqueException |
toTorqueException(SQLException e)
Creates a Torque exception from a database-specific exception. |
String |
toUpperCase(String in)
Wraps the input string in a database function to change it to upper case. |
void |
unlockTable(Connection con,
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 String ADAPTER_KEY
static final String DRIVER_KEY
static final String AUTODETECT_ADAPTER
Method Detail |
---|
String toUpperCase(String in)
in
- The string to transform to upper case, may be a literal string,
a prepared statement replacement placeholder(*) or any other
database expression.
char getStringDelimiter()
IDMethod getIDMethodType()
IDMethod
interface denoting which
type of primary key generation method this type of RDBMS uses.
String getIDMethodSQL(Object obj)
null
.
obj
- Information used for key generation.
void lockTable(Connection con, String table) throws SQLException
con
- The JDBC connection to use.table
- The name of the table to lock.
SQLException
- No Statement could be created or executed.void unlockTable(Connection con, String table) throws SQLException
con
- The JDBC connection to use.table
- The name of the table to unlock.
SQLException
- No Statement could be created or executed.String ignoreCase(String in)
in
- The string to transform to a case-insensitive representation,
may be a literal string, a prepared statement replacement
placeholder(*) or any other database expression.
String ignoreCaseInOrderBy(String in)
in
- The string whose case to ignore.
boolean supportsNativeLimit()
boolean supportsNativeOffset()
void generateLimits(Query query, long 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()
boolean useIlike()
boolean useEscapeClauseForLike()
TorqueException toTorqueException(SQLException e)
e
- the database-specific exception to create the exception from
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |