Class DBMSHandlerPostgreSQL

java.lang.Object
org.apache.empire.dbms.DBMSHandlerBase
org.apache.empire.dbms.postgresql.DBMSHandlerPostgreSQL
All Implemented Interfaces:
DBMSHandler

public class DBMSHandlerPostgreSQL extends DBMSHandlerBase
This class provides support for the PostgreSQL database system.
  • Field Details

    • POSTGRES_KEYWORDS

      protected static final String[] POSTGRES_KEYWORDS
  • Constructor Details

    • DBMSHandlerPostgreSQL

      public DBMSHandlerPostgreSQL()
      Constructor for the PostgreSQL database dbms.
  • Method Details

    • getDatabaseName

      public String getDatabaseName()
      returns the name for the database / schema
      Returns:
      the database / schema name
    • isUsePostgresSerialType

      public boolean isUsePostgresSerialType()
      Returns whether or not the Postgres Serial Type is used for Identity columns
      Returns:
      true if Postgres Serial Type is used or false if INTEGER is used
    • setUsePostgresSerialType

      public void setUsePostgresSerialType(boolean usePostgresSerialType)
      Sets whether or not the Postgres Serial Type is used for Identity columns
      Parameters:
      usePostgresSerialType - true if Postgres Serial Type should be used or false if INTEGER should be used
    • setDatabaseName

      public void setDatabaseName(String databaseName)
      Sets the name for the database / schema
      This names is required for creating a database.
      When a name is set, the dbms will automatically execute 'USE dbname' when the database is opened.
      Parameters:
      databaseName - the name of the database
    • attachDatabase

      public void attachDatabase(DBDatabase db, Connection conn)
      Initialize Database on open
      Specified by:
      attachDatabase in interface DBMSHandler
      Overrides:
      attachDatabase in class DBMSHandlerBase
      Parameters:
      db - the database
      conn - the Jdbc connection
    • createCommand

      public DBCommandPostgres createCommand(boolean autoPrepareStmt)
      Creates a new PostgreSQL command object.
      Specified by:
      createCommand in interface DBMSHandler
      Overrides:
      createCommand in class DBMSHandlerBase
      Parameters:
      autoPrepareStmt - flag whether to automatically provide literal values as prepared statement params
      Returns:
      the new DBCommandPostgreSQL object
    • isSupported

      public boolean isSupported(DBMSFeature type)
      Returns whether or not a particular feature is supported by this dbms
      Specified by:
      isSupported in interface DBMSHandler
      Specified by:
      isSupported in class DBMSHandlerBase
      Parameters:
      type - type of requested feature. @see DBMSFeature
      Returns:
      true if the features is supported or false otherwise
    • getSQLPhrase

      public String getSQLPhrase(DBSqlPhrase phrase)
      Gets an sql phrase template for this database system.
      Parameters:
      phrase - the identifier of the phrase
      Returns:
      the phrase template
      See Also:
    • getConvertPhrase

      public String getConvertPhrase(DataType destType, DataType srcType, Object format)
      Description copied from interface: DBMSHandler
      Returns a data type convertion phrase template for this dbms
      The returned template must contain a '?' which will be replaced by a column expression.
      Parameters:
      destType - the target data type
      srcType - the source data type
      format - additional formatting information (optional)
      Returns:
      the data conversion phrase template
      See Also:
    • getNextSequenceValue

      public Object getNextSequenceValue(DBDatabase db, String seqName, int minValue, Connection conn)
      Description copied from class: DBMSHandlerBase
      Returns the next value of a named sequence The numbers are used for fields of type DBExpr.DT_AUTOINC.
      If a dbms supports this function it must return true for isSupported(DBMSFeature.SEQUENCES).
      Specified by:
      getNextSequenceValue in class DBMSHandlerBase
      Parameters:
      db - the database
      seqName - the name of the sequence
      minValue - the minimum value of the sequence
      conn - a valid database connection
      Returns:
      a new unique sequence value or null if an error occurred
      See Also:
    • getNextSequenceValueExpr

      public DBColumnExpr getNextSequenceValueExpr(DBTableColumn column)
      Description copied from class: DBMSHandlerBase
      Returns an expression for creating a sequence value. This is intended for the use with INSERT INTO statements where many records are affected.
      Specified by:
      getNextSequenceValueExpr in class DBMSHandlerBase
      Parameters:
      column - the column for which to obtain an expression providing the next sequence value
      Returns:
      an expression for the next sequence value
      See Also:
    • getUpdateTimestamp

      public Timestamp getUpdateTimestamp(Connection conn)
      Overridden. Returns a timestamp that is used for record updates created by the database server.
      Specified by:
      getUpdateTimestamp in interface DBMSHandler
      Overrides:
      getUpdateTimestamp in class DBMSHandlerBase
      Parameters:
      conn - the connection that might be used
      Returns:
      the current date and time of the database server.
    • getDDLGenerator

      public PostgresDDLGenerator getDDLGenerator()
      Returns the Postgres DDL Generator
    • getDDLScript

      public void getDDLScript(DBDDLGenerator.DDLActionType type, DBObject dbo, DBSQLScript script)
      Description copied from interface: DBMSHandler
      Appends the required DLL commands to create, drop or alter an object to the supplied DBDQLScript.
      Parameters:
      type - operation to perform (CREATE, DROP, ALTER)
      dbo - the object for which to perform the operation (DBDatabase, DBTable, DBView, DBColumn, DBRelation)
      script - the script to which to add the DDL command(s)
      See Also:
    • getResultValue

      public Object getResultValue(ResultSet rset, int columnIndex, DataType dataType) throws SQLException
      Postgre needs special handling for CLOBs and BLOB's
      Specified by:
      getResultValue in interface DBMSHandler
      Overrides:
      getResultValue in class DBMSHandlerBase
      Parameters:
      rset - the sql Resultset with the current data row
      columnIndex - one based column Index of the desired column
      dataType - the required data type
      Returns:
      the value of the Column
      Throws:
      SQLException - if a database access error occurs
    • initSerialSequenceNames

      protected void initSerialSequenceNames(DBDatabase db, Connection conn)
      Initializes the Sequence names of SERIAL and BIGSERIAL columns
      Parameters:
      db - the database for which to set the sequence names
      conn - the connection