org.apache.torque.adapter
Class DBPostgres

java.lang.Object
  extended by org.apache.torque.adapter.AbstractDBAdapter
      extended by org.apache.torque.adapter.DBPostgres
All Implemented Interfaces:
java.io.Serializable, DB, IDMethod

public class DBPostgres
extends AbstractDBAdapter

This is used to connect to PostgresQL databases. http://www.postgresql.org/

Version:
$Id: DBPostgres.java 522044 2007-03-24 16:00:57Z tfischer $
Author:
Hakan Tandogan, Henning P. Schmiedehausen
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.apache.torque.adapter.DB
ADAPTER_KEY, DRIVER_KEY, LIMIT_STYLE_DB2, LIMIT_STYLE_MYSQL, LIMIT_STYLE_NONE, LIMIT_STYLE_ORACLE, LIMIT_STYLE_POSTGRES, LIMIT_STYLE_SYBASE
 
Fields inherited from interface org.apache.torque.adapter.IDMethod
AUTO_INCREMENT, ID_BROKER, NATIVE, NO_ID_METHOD, SEQUENCE
 
Constructor Summary
protected DBPostgres()
          Empty constructor.
 
Method Summary
 void generateLimits(Query query, int offset, int limit)
          Generate a LIMIT limit OFFSET offset clause if offset > 0 or an LIMIT limit clause if limit is > 0 and offset is 0.
 java.lang.String getBooleanString(java.lang.Boolean b)
          Override the default behavior to associate b with null?
 java.lang.String getDateString(java.util.Date date)
          This method overrides the JDBC escapes used to format dates using a DateFormat.
 java.lang.String getIDMethodSQL(java.lang.Object name)
          Returns SQL used to get the most recently inserted primary key.
 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()
          Deprecated. This should not be exposed to the outside
 java.lang.String ignoreCase(java.lang.String in)
          This method is used to ignore case.
 void lockTable(java.sql.Connection con, java.lang.String table)
          Locks the specified table.
 boolean supportsNativeLimit()
          Return true for PostgreSQL
 boolean supportsNativeOffset()
          Return true for PostgreSQL
 java.lang.String toUpperCase(java.lang.String in)
          This method is used to ignore case.
 void unlockTable(java.sql.Connection con, java.lang.String table)
          Unlocks the specified table.
 boolean useIlike()
          Whether ILIKE should be used for case insensitive like clauses.
 
Methods inherited from class org.apache.torque.adapter.AbstractDBAdapter
escapeText, getFunctionClass, getStringDelimiter, ignoreCaseInOrderBy, useEscapeClauseForLike
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBPostgres

protected DBPostgres()
Empty constructor.

Method Detail

toUpperCase

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

Specified by:
toUpperCase in interface DB
Specified by:
toUpperCase in class AbstractDBAdapter
Parameters:
in - The string to transform to upper case.
Returns:
The upper case string.

ignoreCase

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

Specified by:
ignoreCase in interface DB
Specified by:
ignoreCase in class AbstractDBAdapter
Parameters:
in - The string whose case to ignore.
Returns:
The string in a case that can be ignored.

getIDMethodType

public java.lang.String getIDMethodType()
Description copied from class: AbstractDBAdapter
Returns the constant from the IDMethod interface denoting which type of primary key generation method this type of RDBMS uses.

Specified by:
getIDMethodType in interface DB
Specified by:
getIDMethodType in class AbstractDBAdapter
Returns:
IDMethod constant
See Also:
DB.getIDMethodType()

getIDMethodSQL

public java.lang.String getIDMethodSQL(java.lang.Object name)
Description copied from class: AbstractDBAdapter
Returns SQL used to get the most recently inserted primary key. Databases which have no support for this return null.

Specified by:
getIDMethodSQL in interface DB
Specified by:
getIDMethodSQL in class AbstractDBAdapter
Parameters:
name - The name of the field (should be of type String).
Returns:
SQL to retreive the next database key.
See Also:
DB.getIDMethodSQL(Object)

lockTable

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

Specified by:
lockTable in interface DB
Specified by:
lockTable in class AbstractDBAdapter
Parameters:
con - The JDBC connection to use.
table - The name of the table to lock.
Throws:
java.sql.SQLException - No Statement could be created or executed.

unlockTable

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

Specified by:
unlockTable in interface DB
Specified by:
unlockTable in class AbstractDBAdapter
Parameters:
con - The JDBC connection to use.
table - The name of the table to unlock.
Throws:
java.sql.SQLException - No Statement could be created or executed.

getLimitStyle

public int getLimitStyle()
Deprecated. This should not be exposed to the outside

This method is used to chek whether the database supports limiting the size of the resultset.

Specified by:
getLimitStyle in interface DB
Overrides:
getLimitStyle in class AbstractDBAdapter
Returns:
LIMIT_STYLE_POSTGRES.

supportsNativeLimit

public boolean supportsNativeLimit()
Return true for PostgreSQL

Specified by:
supportsNativeLimit in interface DB
Overrides:
supportsNativeLimit in class AbstractDBAdapter
Returns:
True if the database natively supports limiting the size of the resultset.
See Also:
AbstractDBAdapter.supportsNativeLimit()

supportsNativeOffset

public boolean supportsNativeOffset()
Return true for PostgreSQL

Specified by:
supportsNativeOffset in interface DB
Overrides:
supportsNativeOffset in class AbstractDBAdapter
Returns:
True if the database natively supports returning results starting at an offset position other than 0.
See Also:
AbstractDBAdapter.supportsNativeOffset()

generateLimits

public void generateLimits(Query query,
                           int offset,
                           int limit)
Generate a LIMIT limit OFFSET offset clause if offset > 0 or an LIMIT limit clause if limit is > 0 and offset is 0.

Specified by:
generateLimits in interface DB
Overrides:
generateLimits in class AbstractDBAdapter
Parameters:
query - The query to modify
offset - the offset Value
limit - the limit Value

getBooleanString

public java.lang.String getBooleanString(java.lang.Boolean b)
Override the default behavior to associate b with null?

Specified by:
getBooleanString in interface DB
Overrides:
getBooleanString in class AbstractDBAdapter
Parameters:
b - the Boolean to format
Returns:
The proper date formatted String.
See Also:
DB.getBooleanString(Boolean)

getDateString

public java.lang.String getDateString(java.util.Date date)
This method overrides the JDBC escapes used to format dates using a DateFormat. This generates the timedate format defined in http://www.postgresql.org/docs/7.3/static/datatype-datetime.html which defined PostgreSQL dates as YYYY-MM-DD hh:mm:ss

Specified by:
getDateString in interface DB
Overrides:
getDateString in class AbstractDBAdapter
Parameters:
date - the date to format
Returns:
The properly formatted date String.

useIlike

public boolean useIlike()
Whether ILIKE should be used for case insensitive like clauses. As postgres uses ILIKE, this mimplementation returns true.

Specified by:
useIlike in interface DB
Overrides:
useIlike in class AbstractDBAdapter
Returns:
true if ilike should be used for case insensitive likes, false if ignoreCase should be applied to the compared strings.


Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.