|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.torque.adapter.DB
DB
defines the interface for a Torque database
adapter. Support for new databases is added by subclassing
DB
and implementing its abstract interface, and by
registering the new database adapter and its corresponding
JDBC driver 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.
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 int |
LIMIT_STYLE_MYSQL
SELECT ... |
static int |
LIMIT_STYLE_NONE
Database does not support limiting result sets. |
static int |
LIMIT_STYLE_ORACLE
|
static int |
LIMIT_STYLE_POSTGRES
SELECT ... |
static int |
LIMIT_STYLE_SYBASE
SET ROWCOUNT <offset> SELECT ... |
Fields inherited from interface org.apache.torque.adapter.IDMethod |
AUTO_INCREMENT, ID_BROKER, NATIVE, NO_ID_METHOD, SEQUENCE |
Constructor Summary | |
protected |
DB()
Empty constructor. |
Method Summary | |
boolean |
escapeText()
This method is for the SqlExpression.quoteAndEscape rules. |
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. |
abstract java.lang.String |
getIDMethodSQL(java.lang.Object obj)
Returns SQL used to get the most recently inserted primary key. |
abstract 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()
This method is used to check whether the database supports limiting the size of the resultset. |
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). |
abstract java.lang.String |
ignoreCase(java.lang.String in)
This method is used to ignore case. |
java.lang.String |
ignoreCaseInOrderBy(java.lang.String in)
This method is used to ignore case in an ORDER BY clause. |
abstract 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. |
abstract java.lang.String |
toUpperCase(java.lang.String in)
This method is used to ignore case. |
abstract void |
unlockTable(java.sql.Connection con,
java.lang.String table)
Unlocks the specified table. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int LIMIT_STYLE_NONE
public static final int LIMIT_STYLE_POSTGRES
SELECT ... LIMIT , [<offset>]
public static final int LIMIT_STYLE_MYSQL
SELECT ... LIMIT [, ] <offset>
public static final int LIMIT_STYLE_SYBASE
SET ROWCOUNT <offset> SELECT ... SET ROWCOUNT 0
public static final int LIMIT_STYLE_ORACLE
SELECT ... WHERE ... AND ROWNUM <
Constructor Detail |
protected DB()
Method Detail |
public abstract java.lang.String toUpperCase(java.lang.String in)
in
- The string to transform to upper case.
public char getStringDelimiter()
public abstract java.lang.String getIDMethodType()
IDMethod
interface denoting which
type of primary key generation method this type of RDBMS uses.
public abstract java.lang.String getIDMethodSQL(java.lang.Object obj)
null
.
obj
- Information used for key generation.
public abstract 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.public abstract 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.public abstract java.lang.String ignoreCase(java.lang.String in)
in
- The string whose case to ignore.
public java.lang.String ignoreCaseInOrderBy(java.lang.String in)
in
- The string whose case to ignore.
public boolean supportsNativeLimit()
public boolean supportsNativeOffset()
public boolean escapeText()
public int getLimitStyle()
public java.lang.String getDateString(java.util.Date date)
date
- the Date to format
public java.lang.String getBooleanString(java.lang.Boolean b)
b
- the Boolean to format
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |