net.java.ao
Class PoolProvider

java.lang.Object
  extended by net.java.ao.DatabaseProvider
      extended by net.java.ao.PoolProvider
Direct Known Subclasses:
C3P0PoolProvider, DBCPPoolProvider, ProxoolPoolProvider

public abstract class PoolProvider
extends DatabaseProvider

Author:
Daniel Spiewak

Constructor Summary
protected PoolProvider(DatabaseProvider delegate)
           
 
Method Summary
 void dispose()
           
 DatabaseProvider getDelegate()
           
 java.lang.Class<? extends java.sql.Driver> getDriverClass()
          Returns the JDBC Driver class which corresponds to the database being abstracted.
 java.sql.ResultSet getTables(java.sql.Connection conn)
           
 int insertReturningKeys(java.sql.Connection conn, java.lang.String table, DBParam... params)
           
 java.lang.Object parseValue(int type, java.lang.String value)
          Parses the database-agnostic String value relevant to the specified SQL type in int form (as defined by Types and returns the Java value which corresponds.
 java.lang.String[] renderAction(DDLAction action)
          Top level delegating method for the process of rendering a database-agnostic DDLAction into the database-specific DDL statement(s).
protected  java.lang.String renderAutoIncrement()
          Generates the DDL fragment required to specify an INTEGER field as auto-incremented.
 java.lang.String renderQuery(Query query, TableNameConverter converter, boolean count)
          Top level delegating method for rendering a database-agnostic Query object into its (potentially) database-specific query statement.
protected  void setPostConnectionProperties(java.sql.Connection conn)
           
 void setQueryResultSetProperties(java.sql.ResultSet res, Query query)
           
 void setQueryStatementProperties(java.sql.Statement stmt, Query query)
           
 
Methods inherited from class net.java.ao.DatabaseProvider
considerPrecision, convertTypeToString, executeInsertReturningKeys, getConnection, getConnectionImpl, getDateFormat, getFunctionNameForField, getInstance, getInstance, getPassword, getTriggerNameForField, getURI, getUsername, isNumericType, renderAlterTableAddColumn, renderAlterTableAddKey, renderAlterTableChangeColumn, renderAlterTableDropColumn, renderAlterTableDropKey, renderAppend, renderCalendar, renderConstraintsForTable, renderDropFunctions, renderDropTable, renderDropTriggers, renderField, renderFieldType, renderForeignKey, renderFunction, renderFunctionForField, renderFunctions, renderOnUpdate, renderQueryGroupBy, renderQueryJoins, renderQueryLimit, renderQueryOrderBy, renderQuerySelect, renderQueryWhere, renderTable, renderTriggerForField, renderTriggers, renderUnique, renderValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PoolProvider

protected PoolProvider(DatabaseProvider delegate)
Method Detail

getDriverClass

public java.lang.Class<? extends java.sql.Driver> getDriverClass()
                                                          throws java.lang.ClassNotFoundException
Description copied from class: DatabaseProvider

Returns the JDBC Driver class which corresponds to the database being abstracted. This should be implemented in such a way as to initialize and register the driver with JDBC. For most drivers, this requires code in the following form:

public Class<? extends Driver> getDriverClass() {
     return (Class<? extends Driver>) Class.forName("com.mysql.jdbc.Driver");
 }

The following does not fire the driver's static initializer and thus will (usually) not work:

public Class<? extends Driver> getDriverClass() {
     return com.mysql.jdbc.Driver.class;
 }

If the driver is not on the classpath, a ClassNotFoundException can and should be thrown (certain auto-magic configuration sections of ActiveObjects depend upon this under certain circumstances).

Specified by:
getDriverClass in class DatabaseProvider
Throws:
java.lang.ClassNotFoundException

getDelegate

public final DatabaseProvider getDelegate()

parseValue

public java.lang.Object parseValue(int type,
                                   java.lang.String value)
Description copied from class: DatabaseProvider

Parses the database-agnostic String value relevant to the specified SQL type in int form (as defined by Types and returns the Java value which corresponds. This method is completely database-agnostic, as are all of all of its delegate methods.

WARNING: This method is being considered for removal to another class (perhaps TypeManager?) as it is not a database-specific function and thus confuses the purpose of this class. Do not rely upon it heavily. (better yet, don't rely on it at all from external code. It's not designed to be part of the public API)

Overrides:
parseValue in class DatabaseProvider
Parameters:
type - The JDBC integer type of the database field against which to parse the value.
value - The database-agnostic String value to parse into a proper Java object with respect to the specified SQL type.

renderAction

public java.lang.String[] renderAction(DDLAction action)
Description copied from class: DatabaseProvider
Top level delegating method for the process of rendering a database-agnostic DDLAction into the database-specific DDL statement(s). It is doubtful that any implementations will have to override this method as the default implementation is database-agnostic.

Overrides:
renderAction in class DatabaseProvider
Parameters:
action - The database-agnostic action to render.
See Also:
DatabaseProvider.renderTable(DDLTable), DatabaseProvider.renderFunctions(DDLTable), DatabaseProvider.renderTriggers(DDLTable), DatabaseProvider.renderDropTriggers(DDLTable), DatabaseProvider.renderDropFunctions(DDLTable), DatabaseProvider.renderDropTable(DDLTable), DatabaseProvider.renderAlterTableAddColumn(DDLTable, DDLField), DatabaseProvider.renderAlterTableChangeColumn(DDLTable, DDLField, DDLField), DatabaseProvider.renderAlterTableDropColumn(DDLTable, DDLField), DatabaseProvider.renderAlterTableAddKey(DDLForeignKey), DatabaseProvider.renderAlterTableDropKey(DDLForeignKey)

renderQuery

public java.lang.String renderQuery(Query query,
                                    TableNameConverter converter,
                                    boolean count)
Description copied from class: DatabaseProvider

Top level delegating method for rendering a database-agnostic Query object into its (potentially) database-specific query statement. This method invokes the various renderQuery* methods to construct its output, thus it is doubtful that any subclasses will have to override it. Rather, one of the delegate methods should be considered.

An example of a database-specific query rendering would be the following Query:

Query.select().from(Person.class).limit(10)

On MySQL, this would render to SELECT id FROM people LIMIT 10 However, on SQL Server, this same Query would render as SELECT TOP 10 id FROM people

Overrides:
renderQuery in class DatabaseProvider
Parameters:
query - The database-agnostic Query object to be rendered in a potentially database-specific way.
converter - Used to convert Entity classes into table names.
count - If true, render the Query as a SELECT COUNT(*) rather than a standard field-data query.
See Also:
DatabaseProvider.renderQuerySelect(Query, TableNameConverter, boolean), DatabaseProvider.renderQueryJoins(Query, TableNameConverter), DatabaseProvider.renderQueryWhere(Query), DatabaseProvider.renderQueryGroupBy(Query), DatabaseProvider.renderQueryOrderBy(Query), DatabaseProvider.renderQueryLimit(Query)

setQueryStatementProperties

public void setQueryStatementProperties(java.sql.Statement stmt,
                                        Query query)
                                 throws java.sql.SQLException
Overrides:
setQueryStatementProperties in class DatabaseProvider
Throws:
java.sql.SQLException

setQueryResultSetProperties

public void setQueryResultSetProperties(java.sql.ResultSet res,
                                        Query query)
                                 throws java.sql.SQLException
Overrides:
setQueryResultSetProperties in class DatabaseProvider
Throws:
java.sql.SQLException

getTables

public java.sql.ResultSet getTables(java.sql.Connection conn)
                             throws java.sql.SQLException
Overrides:
getTables in class DatabaseProvider
Throws:
java.sql.SQLException

insertReturningKeys

public int insertReturningKeys(java.sql.Connection conn,
                               java.lang.String table,
                               DBParam... params)
                        throws java.sql.SQLException
Overrides:
insertReturningKeys in class DatabaseProvider
Throws:
java.sql.SQLException

setPostConnectionProperties

protected void setPostConnectionProperties(java.sql.Connection conn)
                                    throws java.sql.SQLException
Overrides:
setPostConnectionProperties in class DatabaseProvider
Throws:
java.sql.SQLException

renderAutoIncrement

protected java.lang.String renderAutoIncrement()
Description copied from class: DatabaseProvider

Generates the DDL fragment required to specify an INTEGER field as auto-incremented. For databases which do not support such flags (which is just about every database exception MySQL), "" is an acceptable return value. This method should never return null as it would cause the field rendering method to throw a NullPointerException.

This method is abstract (as opposed to the other methods which are either defined against MySQL or simply empty) because of the vast differences in rendering auto-incremented fields across different databases. Also, it seemed like a terribly good idea at the time and I haven't found a compelling reason to change it.

Specified by:
renderAutoIncrement in class DatabaseProvider

dispose

public void dispose()
Overrides:
dispose in class DatabaseProvider