com.triactive.jdo.store.adapter
Class PostgresqlAdapter

java.lang.Object
  extended bycom.triactive.jdo.store.adapter.DatabaseAdapter
      extended bycom.triactive.jdo.store.adapter.PostgresqlAdapter

public class PostgresqlAdapter
extends DatabaseAdapter

Provides methods for adapting SQL language elements to the PostgreSQL database.

Author:
Levente Sántha, Mike Martin

Field Summary
 
Fields inherited from class com.triactive.jdo.store.adapter.DatabaseAdapter
dbid, identifierQuoteString, keywords, maxCatalogNameLength, maxColumnNameLength, maxConstraintNameLength, maxCorrelationNameLength, maxIndexNameLength, maxSchemaNameLength, maxTableNameLength, storesLowerCaseIdentifiers, storesUpperCaseIdentifiers, supportsCorrelatedSubqueries, supportsGroupByUnrelated, supportsOrderByUnrelated, supportsSubqueriesInExists, supportsSubqueriesInIns, typeMappings, types
 
Constructor Summary
PostgresqlAdapter()
           
 
Method Summary
protected  void adaptTo(DatabaseIdentifier dbid, java.sql.DatabaseMetaData metadata)
          Initializes the database adapter based on the given JDBC metadata.
 java.lang.String getDropTableStatement(BaseTable table)
          Returns the appropriate SQL to drop the given table.
protected  java.lang.String getQueryCurrentSchemaNameStatement()
          Returns a statement that will return the name of the current schema.
protected  java.lang.String getQueryCurrentTimestampStatement()
          Returns a statement that will return a timestamp reflecting the database's current date and time.
 SqlState getSqlState(java.sql.SQLException se)
          Returns a SqlState object for the specified SQLException, if one is present and valid.
 ColumnInfo newColumnInfo(java.sql.ResultSet rs)
          A factory for ColumnInfo objects.
 ForeignKeyInfo newForeignKeyInfo(java.sql.ResultSet rs)
          A factory for ForeignKeyInfo objects.
 TypeInfo newTypeInfo(java.sql.ResultSet rs, int row)
          A factory for TypeInfo objects.
 
Methods inherited from class com.triactive.jdo.store.adapter.DatabaseAdapter
avgFunction, bitTypeIsReallyBoolean, cast, countFunction, createIndexesBeforeForeignKeys, createTypeInfo, getAddCandidateKeyStatement, getAddForeignKeyStatement, getAddPrimaryKeyStatement, getBestIdentifyingPatterns, getCreateIndexStatement, getCreateTableStatement, getCurrentTimestamp, getDropForeignKeyStatement, getDropViewStatement, getIdentifierQuoteString, getInstance, getMaxCatalogNameLength, getMaxColumnNameLength, getMaxConstraintNameLength, getMaxCorrelationNameLength, getMaxIndexNameLength, getMaxPreparedStatementParameters, getMaxSchemaNameLength, getMaxTableNameLength, getSchemaName, getTypeInfo, getTypeInfo, getUnlimitedLengthPrecisionValue, getVendorID, isBestAdapterFor, isEmbeddedType, isSqlKeyword, lengthMethod, mappingClassFor, mappingClassFor, maxFunction, minFunction, newColumnMapping, newDataStoreException, newIndexInfo, newMapping, newMapping, newPrimaryKeyInfo, newQueryStatement, newQueryStatement, newQueryStatement, newTableExpression, newTableInfo, parseKeywordList, storesLowerCaseIdentifiers, storesUpperCaseIdentifiers, substringMethod, substringMethod, sumFunction, supportsBooleanComparison, supportsCorrelatedSubqueries, supportsDeferredConstraints, supportsGroupByUnrelated, supportsNullsInCandidateKeys, supportsOrderByUnrelated, supportsSubqueriesInExists, supportsSubqueriesInIns, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PostgresqlAdapter

public PostgresqlAdapter()
Method Detail

adaptTo

protected void adaptTo(DatabaseIdentifier dbid,
                       java.sql.DatabaseMetaData metadata)
                throws java.sql.SQLException
Description copied from class: DatabaseAdapter
Initializes the database adapter based on the given JDBC metadata. Called only once after an adapter object has been selected for use.

Overrides:
adaptTo in class DatabaseAdapter
Parameters:
dbid - the database identifier
metadata - the database metadata
Throws:
java.sql.SQLException

getQueryCurrentSchemaNameStatement

protected java.lang.String getQueryCurrentSchemaNameStatement()
Description copied from class: DatabaseAdapter
Returns a statement that will return the name of the current schema. The statement is expected to return the schema name in the first column of the first row of the result set. There is no generic SQL way to do this so the implementation in this class always throws UnsupportedOperationException.

Overrides:
getQueryCurrentSchemaNameStatement in class DatabaseAdapter
Returns:
a statement to return the name of the current schema.

getQueryCurrentTimestampStatement

protected java.lang.String getQueryCurrentTimestampStatement()
Description copied from class: DatabaseAdapter
Returns a statement that will return a timestamp reflecting the database's current date and time. The statement is expected to return the timestamp in the first column of the first row of the result set. There is no generic SQL way to do this so the implementation in this class always throws UnsupportedOperationException.

Overrides:
getQueryCurrentTimestampStatement in class DatabaseAdapter
Returns:
a statement to return the name of the current schema.

getSqlState

public SqlState getSqlState(java.sql.SQLException se)
Description copied from class: DatabaseAdapter
Returns a SqlState object for the specified SQLException, if one is present and valid.

Overrides:
getSqlState in class DatabaseAdapter
Parameters:
se - A caught SQL exception.
Returns:
A SqlState object, or null if se does not contain a valid 5-character SQLSTATE.

newTypeInfo

public TypeInfo newTypeInfo(java.sql.ResultSet rs,
                            int row)
                     throws java.sql.SQLException
Description copied from class: DatabaseAdapter
A factory for TypeInfo objects. This method should always be used instead of directly constructing TypeInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver. The type information object is constructed from the current row of the given result set. The ResultSet object passed must have been obtained from a call to DatabaseMetaData.getTypeInfo().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next().

Overrides:
newTypeInfo in class DatabaseAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.getTypeInfo().
row - The current row number in the result set. The first row is 1.
Returns:
A TypeInfo object constructed from the current result set row, or null if the type indicated by this row should be excluded from use.
Throws:
java.sql.SQLException - If a database error occurs.

newColumnInfo

public ColumnInfo newColumnInfo(java.sql.ResultSet rs)
                         throws java.sql.SQLException
Description copied from class: DatabaseAdapter
A factory for ColumnInfo objects. This method should always be used instead of directly constructing ColumnInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver.

The column information object is constructed from the current row of the given result set. The result set passed must have been obtained from a call to DatabaseMetaData.getColumns().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next().

Overrides:
newColumnInfo in class DatabaseAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.getColumns().
Throws:
java.sql.SQLException - If a database error occurs.

newForeignKeyInfo

public ForeignKeyInfo newForeignKeyInfo(java.sql.ResultSet rs)
                                 throws java.sql.SQLException
Description copied from class: DatabaseAdapter
A factory for ForeignKeyInfo objects. This method should always be used instead of directly constructing ForeignKeyInfo objects in order to give the DatabaseAdapter an opportunity to modify and/or correct the metadata obtained from the JDBC driver.

The column information object is constructed from the current row of the given result set. The result set passed must have been obtained from a call to DatabaseMetaData.getImportedKeys() or DatabaseMetaData.getExportedKeys().

The constructor only retrieves the values from the current row; the caller is required to advance to the next row with ResultSet.next().

Overrides:
newForeignKeyInfo in class DatabaseAdapter
Parameters:
rs - The result set returned from DatabaseMetaData.get??portedKeys().
Throws:
java.sql.SQLException - If a database error occurs.

getDropTableStatement

public java.lang.String getDropTableStatement(BaseTable table)
Description copied from class: DatabaseAdapter
Returns the appropriate SQL to drop the given table. It should return something like:

 DROP TABLE FOO CASCADE
 

Overrides:
getDropTableStatement in class DatabaseAdapter
Parameters:
table - The table to drop.
Returns:
The text of the SQL statement.


Copyright © 2001-2007 The TJDO Project All Rights Reserved.