Class DerbyTranslator

    • Constructor Summary

      Constructors 
      Constructor Description
      DerbyTranslator()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String addForUpdate​(java.lang.String sql)
      Append FOR UPDATE/FOR UPDATE WITH RS depending on the target DB type
      boolean clobSupportsInline()
      Does the database support inlining for clobs
      java.lang.String createGlobalTempTable​(java.lang.String ddl)  
      java.lang.String createSequence​(java.lang.String name, int cache)
      Craft the DDL for a CREATE SEQUENCE statement
      java.lang.String currentTimestampString()
      Get the "CURRENT TIMESTAMP" string for the database type
      java.lang.String dropForeignKeyConstraint​(java.lang.String qualifiedTableName, java.lang.String constraintName)
      Generate the DDL for dropping the named FK constraint from the given table
      java.lang.String dropView​(java.lang.String qualifiedViewName)
      Generate the DDL for dropping the named view
      java.lang.String dualTableName()
      The name of the "DUAL" table...that special table giving us one row/column.
      void fillProperties​(java.util.Properties p, ConnectionDetails cd)
      Configure the properties using information from the ConnectionDetails
      java.lang.String getDriverClassName()
      Get the driver class to use for connections
      DbType getType()
      The main type of the database
      java.lang.String getUrl​(java.util.Properties connectionProperties)
      Get the JDBC connection URL based on the properties
      java.lang.String globalTempTableName​(java.lang.String tableName)
      Get the proper table name based on the type of database we are connected to.
      boolean isAlreadyExists​(java.sql.SQLException x)
      Check the exception to see if it is reporting that THE NAME OF THE OBJECT TO BE CREATED OR THE TARGET OF A RENAME STATEMENT IS IDENTICAL TO THE EXISTING NAME OF THE OBJECT TYPE
      boolean isConnectionError​(java.sql.SQLException x)
      Returns true if the exception represents a connection error
      boolean isDeadlock​(java.sql.SQLException x)
      Was this statement the victim of a deadlock
      boolean isDerby()
      Are we working with a Derby database
      boolean isDuplicate​(java.sql.SQLException x)
      Check the exception to see if it is reporting a duplicate value constraint violation
      boolean isFamilyPostgreSQL()
      True if the database type is part of the PostgreSQL family (POSTGRESQL, CITUS)
      boolean isLockTimeout​(java.sql.SQLException x)
      Database timed out waiting to get a lock.
      boolean isUndefinedName​(java.sql.SQLException x)
      Returns true if the SQLException is indicating an object is undefined (e.g.
      java.lang.String limit​(java.lang.String arg)
      Get the correct LIMIT/FETCH NEXT ROWS clause for the database
      java.lang.String nextValue​(java.lang.String schemaName, java.lang.String sequenceName)
      Statement for getting the next value (for use in a select list or insert values)
      java.lang.String pagination​(int offset, int rowsPerPage)
      Construct a pagination clause specific to the type of database
      java.lang.String reorgTableCommand​(java.lang.String tableName)
      Return the REORG TABLE command if supported, or null otherwise
      java.lang.String selectSequenceNextValue​(java.lang.String schemaName, java.lang.String sequenceName)
      Compose a select statement to obtain the next value from the named sequence
      java.lang.String timestampDiff​(java.lang.String left, java.lang.String right, java.lang.String alias)
      Returns an expression which computes the timestamp difference between left and right in seconds
      DataAccessException translate​(java.sql.SQLException x)
      Get an appropriate instance of ReplicatorException to throw depending on the details of SQLException
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DerbyTranslator

        public DerbyTranslator()
    • Method Detail

      • addForUpdate

        public java.lang.String addForUpdate​(java.lang.String sql)
        Description copied from interface: IDatabaseTranslator
        Append FOR UPDATE/FOR UPDATE WITH RS depending on the target DB type
        Specified by:
        addForUpdate in interface IDatabaseTranslator
        Returns:
      • globalTempTableName

        public java.lang.String globalTempTableName​(java.lang.String tableName)
        Description copied from interface: IDatabaseTranslator
        Get the proper table name based on the type of database we are connected to. Derby has its own handling of temp tables
        Specified by:
        globalTempTableName in interface IDatabaseTranslator
        Returns:
      • isDuplicate

        public boolean isDuplicate​(java.sql.SQLException x)
        Description copied from interface: IDatabaseTranslator
        Check the exception to see if it is reporting a duplicate value constraint violation
        Specified by:
        isDuplicate in interface IDatabaseTranslator
        Returns:
      • isAlreadyExists

        public boolean isAlreadyExists​(java.sql.SQLException x)
        Description copied from interface: IDatabaseTranslator
        Check the exception to see if it is reporting that THE NAME OF THE OBJECT TO BE CREATED OR THE TARGET OF A RENAME STATEMENT IS IDENTICAL TO THE EXISTING NAME OF THE OBJECT TYPE
        Specified by:
        isAlreadyExists in interface IDatabaseTranslator
        Returns:
      • isLockTimeout

        public boolean isLockTimeout​(java.sql.SQLException x)
        Description copied from interface: IDatabaseTranslator
        Database timed out waiting to get a lock. This is not the same as a deadlock, of course
        Specified by:
        isLockTimeout in interface IDatabaseTranslator
        Returns:
      • isConnectionError

        public boolean isConnectionError​(java.sql.SQLException x)
        Description copied from interface: IDatabaseTranslator
        Returns true if the exception represents a connection error
        Specified by:
        isConnectionError in interface IDatabaseTranslator
        Returns:
      • isUndefinedName

        public boolean isUndefinedName​(java.sql.SQLException x)
        Description copied from interface: IDatabaseTranslator
        Returns true if the SQLException is indicating an object is undefined (e.g. "DROP TABLE foo.bar", where table "foo.bar" doesn't exist)
        Specified by:
        isUndefinedName in interface IDatabaseTranslator
        Returns:
      • timestampDiff

        public java.lang.String timestampDiff​(java.lang.String left,
                                              java.lang.String right,
                                              java.lang.String alias)
        Description copied from interface: IDatabaseTranslator
        Returns an expression which computes the timestamp difference between left and right in seconds
        Specified by:
        timestampDiff in interface IDatabaseTranslator
        alias - adds " AS alias " if alias is not null
        Returns:
      • createSequence

        public java.lang.String createSequence​(java.lang.String name,
                                               int cache)
        Description copied from interface: IDatabaseTranslator
        Craft the DDL for a CREATE SEQUENCE statement
        Specified by:
        createSequence in interface IDatabaseTranslator
        cache - the number of sequence values to cache, if supported by the database
        Returns:
      • reorgTableCommand

        public java.lang.String reorgTableCommand​(java.lang.String tableName)
        Description copied from interface: IDatabaseTranslator
        Return the REORG TABLE command if supported, or null otherwise
        Specified by:
        reorgTableCommand in interface IDatabaseTranslator
        Returns:
      • getUrl

        public java.lang.String getUrl​(java.util.Properties connectionProperties)
        Description copied from interface: IDatabaseTranslator
        Get the JDBC connection URL based on the properties
        Specified by:
        getUrl in interface IDatabaseTranslator
        Returns:
      • dualTableName

        public java.lang.String dualTableName()
        Description copied from interface: IDatabaseTranslator
        The name of the "DUAL" table...that special table giving us one row/column.
        Specified by:
        dualTableName in interface IDatabaseTranslator
        Returns:
        the name of the "DUAL" table for the database, or null if not supported
      • selectSequenceNextValue

        public java.lang.String selectSequenceNextValue​(java.lang.String schemaName,
                                                        java.lang.String sequenceName)
        Description copied from interface: IDatabaseTranslator
        Compose a select statement to obtain the next value from the named sequence
        Specified by:
        selectSequenceNextValue in interface IDatabaseTranslator
        Returns:
      • dropForeignKeyConstraint

        public java.lang.String dropForeignKeyConstraint​(java.lang.String qualifiedTableName,
                                                         java.lang.String constraintName)
        Description copied from interface: IDatabaseTranslator
        Generate the DDL for dropping the named FK constraint from the given table
        Specified by:
        dropForeignKeyConstraint in interface IDatabaseTranslator
        Parameters:
        qualifiedTableName - such as schema.foo_tab
        constraintName - the constraint name of the FK
        Returns:
      • dropView

        public java.lang.String dropView​(java.lang.String qualifiedViewName)
        Description copied from interface: IDatabaseTranslator
        Generate the DDL for dropping the named view
        Specified by:
        dropView in interface IDatabaseTranslator
        Returns:
      • nextValue

        public java.lang.String nextValue​(java.lang.String schemaName,
                                          java.lang.String sequenceName)
        Description copied from interface: IDatabaseTranslator
        Statement for getting the next value (for use in a select list or insert values)
        Specified by:
        nextValue in interface IDatabaseTranslator
        Returns:
      • limit

        public java.lang.String limit​(java.lang.String arg)
        Description copied from interface: IDatabaseTranslator
        Get the correct LIMIT/FETCH NEXT ROWS clause for the database
        Specified by:
        limit in interface IDatabaseTranslator
        Parameters:
        arg - a literal int or ? bind-variable marker
        Returns:
      • pagination

        public java.lang.String pagination​(int offset,
                                           int rowsPerPage)
        Description copied from interface: IDatabaseTranslator
        Construct a pagination clause specific to the type of database
        Specified by:
        pagination in interface IDatabaseTranslator
        Parameters:
        offset - the row offset
        rowsPerPage - limit the number of rows returned (from the offset)
        Returns: