|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.turbine.util.db.adapter.DB
DB
defines the interface for a Turbine database
adapter. Support for new databases is added by subclassing
DB
and implementing its abstract interface, and by
registering the new Turbine database adapter and its corresponding
JDBC driver in the TurbineResources.properties file.
The Turbine 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.
Your adapter must be added to the list of available adapters,
using a database.adapter
entry. The established
naming convention for adapters is the String "DB" prepended to a
mutation of the short class name of the driver (i.e. no package
name) or database name. A JDBC driver corresponding to your
adapter should also be added, using the fullly-qualified class name
of the driver. If no driver is specified for your adapter,
driver.default
is used.
# Configuration for the Mysql/MM adapter. database.adaptor=DBMM database.adaptor.DBMM=org.gjt.mm.mysql.DriverHooks to make your adapter the default may also be added.
#### MySQL MM Driver database.default.driver=org.gjt.mm.mysql.Driver database.default.url=jdbc:mysql://localhost/DATABASENAME
Field Summary | |
protected java.lang.String |
DB_CONNECTION
The database name. |
protected java.lang.String |
DB_PASS
The database password. |
protected java.lang.String |
DB_USER
The database user name. |
private java.lang.String |
JDBCDriver
The JDBC driver. |
static int |
LIMIT_STYLE_MYSQL
SELECT ... |
static int |
LIMIT_STYLE_NONE
database does not support limiting resultsets |
static int |
LIMIT_STYLE_POSTGRES
SELECT ... |
static int |
LIMIT_STYLE_SYBASE
SET ROWCOUNT |
Constructor Summary | |
protected |
DB()
Empty constructor. |
Method Summary | |
boolean |
escapeText()
This method is for the SqlExpression.quoteAndEscape rules. |
java.sql.Connection |
getConnection()
Returns a JDBC Connection from the
DriverManager . |
javax.sql.ConnectionPoolDataSource |
getConnectionPoolDataSource()
Returns a new JDBC PooledConnection . |
abstract java.lang.String |
getIdSqlForAutoIncrement(java.lang.Object obj)
Returns the last auto-increment key. |
java.lang.String |
getJDBCDriver()
Gets the JDBC driver used by this adapter. |
int |
getLimitStyle()
This method is used to chek whether the database supports limiting the size of the resultset. |
abstract java.lang.String |
getSequenceSql(java.lang.Object obj)
Returns the last auto-increment key. |
abstract char |
getStringDelimiter()
Gets the string delimiter (usually '\''). |
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. |
void |
init(java.lang.String url,
java.lang.String username,
java.lang.String password)
Performs basic initialization. |
abstract void |
lockTable(java.sql.Connection con,
java.lang.String table)
Locks the specified table. |
boolean |
objectDataNeedsTrans()
This method is used to chek whether writing large objects to the DB requires a transaction. |
void |
setJDBCDriver(java.lang.String newDriver)
Sets the JDBC driver used by this adapter. |
boolean |
supportsNativeLimit()
This method is used to chek whether the database natively supports limiting the size of the resultset. |
boolean |
supportsNativeOffset()
This method is used to chek 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 |
|
Field Detail |
protected java.lang.String DB_USER
protected java.lang.String DB_PASS
protected java.lang.String DB_CONNECTION
private java.lang.String JDBCDriver
public static final int LIMIT_STYLE_NONE
public static final int LIMIT_STYLE_POSTGRES
public static final int LIMIT_STYLE_MYSQL
public static final int LIMIT_STYLE_SYBASE
Constructor Detail |
protected DB()
Method Detail |
public java.sql.Connection getConnection() throws java.sql.SQLException
Connection
from the
DriverManager
.Connection
object for this
database.java.sql.SQLException
- public javax.sql.ConnectionPoolDataSource getConnectionPoolDataSource() throws java.sql.SQLException
PooledConnection
.
The JDBC driver should support the JDBC 2.0 extenstions. Since the
implementation of this class is driver specific, the actual class
of the JDBC driver that implements the PooledConnection interface
should be defined in the specific DB AdapterPooledConnection
object for this
database.java.sql.SQLException
- if the driver does not support PooledConnection
objectspublic void init(java.lang.String url, java.lang.String username, java.lang.String password) throws java.lang.Exception
url
- The URL of the database to connect to.username
- The name of the user to use when connecting.password
- The user's password.java.lang.Exception
- The JDBC driver could not be loaded or
instantiated.public abstract java.lang.String toUpperCase(java.lang.String in)
in
- The string to transform to upper case.public abstract char getStringDelimiter()
public abstract java.lang.String getIdSqlForAutoIncrement(java.lang.Object obj)
obj
- The string information for generating a key.public abstract java.lang.String getSequenceSql(java.lang.Object obj)
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
- 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
- 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 void setJDBCDriver(java.lang.String newDriver)
newDriver
- The fully-qualified class name of the JDBC
driver to use.public java.lang.String getJDBCDriver()
public boolean objectDataNeedsTrans()
public boolean supportsNativeLimit()
public boolean supportsNativeOffset()
public boolean escapeText()
public int getLimitStyle()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |