Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.torque.adapter
Class DB  view DB download DB.java

java.lang.Object
  extended byorg.apache.torque.adapter.DB
All Implemented Interfaces:
IDMethod, java.io.Serializable
Direct Known Subclasses:
DBAxion, DBCloudscape, DBDB2App, DBDB2Net, DBHypersonicSQL, DBInformix, DBInstantDB, DBInterbase, DBMM, DBNone, DBOdbc, DBOracle, DBPostgres, DBSapDB, DBSybase, DBWeblogic

public abstract class DB
extends java.lang.Object
implements java.io.Serializable, IDMethod

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
 

Version:
$Id: DB.java,v 1.31.2.3 2004/08/06 12:13:12 seade Exp $

Field Summary
static int LIMIT_STYLE_DB2
          
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

LIMIT_STYLE_NONE

public static final int LIMIT_STYLE_NONE
Database does not support limiting result sets.

See Also:
Constant Field Values

LIMIT_STYLE_POSTGRES

public static final int LIMIT_STYLE_POSTGRES
SELECT ... LIMIT , [<offset>]

See Also:
Constant Field Values

LIMIT_STYLE_MYSQL

public static final int LIMIT_STYLE_MYSQL
SELECT ... LIMIT [, ] <offset>

See Also:
Constant Field Values

LIMIT_STYLE_SYBASE

public static final int LIMIT_STYLE_SYBASE
SET ROWCOUNT <offset> SELECT ... SET ROWCOUNT 0

See Also:
Constant Field Values

LIMIT_STYLE_ORACLE

public static final int LIMIT_STYLE_ORACLE
SELECT ... WHERE ... AND ROWNUM < 

See Also:
Constant Field Values

LIMIT_STYLE_DB2

public static final int LIMIT_STYLE_DB2
SELECT ... WHERE ... AND ROW_NUMBER() OVER() < 

See Also:
Constant Field Values
Constructor Detail

DB

protected DB()
Empty constructor.

Method Detail

toUpperCase

public abstract java.lang.String toUpperCase(java.lang.String in)
This method is used to ignore case.


getStringDelimiter

public 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).


getIDMethodType

public 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.


getIDMethodSQL

public abstract java.lang.String getIDMethodSQL(java.lang.Object obj)
Returns SQL used to get the most recently inserted primary key. Databases which have no support for this return null.


lockTable

public abstract void lockTable(java.sql.Connection con,
                               java.lang.String table)
                        throws java.sql.SQLException
Locks the specified table.


unlockTable

public abstract void unlockTable(java.sql.Connection con,
                                 java.lang.String table)
                          throws java.sql.SQLException
Unlocks the specified table.


ignoreCase

public abstract java.lang.String ignoreCase(java.lang.String in)
This method is used to ignore case.


ignoreCaseInOrderBy

public java.lang.String ignoreCaseInOrderBy(java.lang.String in)
This method is used to ignore case in an ORDER BY clause. Usually it is the same as ignoreCase, but some databases (Interbase for example) does not use the same SQL in ORDER BY and other clauses.


supportsNativeLimit

public boolean supportsNativeLimit()
This method is used to check whether the database natively supports limiting the size of the resultset.


supportsNativeOffset

public boolean supportsNativeOffset()
This method is used to check whether the database natively supports returning results starting at an offset position other than 0.


escapeText

public boolean escapeText()
This method is for the SqlExpression.quoteAndEscape rules. The rule is, any string in a SqlExpression with a BACKSLASH will either be changed to "\\" or left as "\". SapDB does not need the escape character.


getLimitStyle

public int getLimitStyle()
This method is used to check whether the database supports limiting the size of the resultset.


getDateString

public java.lang.String getDateString(java.util.Date date)
This method is used to format any date string. Database can use different default date formats.


getBooleanString

public java.lang.String getBooleanString(java.lang.Boolean b)
This method is used to format a boolean string.