Class PostgresTranslator
- java.lang.Object
- 
- com.ibm.fhir.database.utils.postgres.PostgresTranslator
 
- 
- All Implemented Interfaces:
- IDatabaseTranslator
 
 public class PostgresTranslator extends Object implements IDatabaseTranslator translates database access to Postgres supported access.
- 
- 
Constructor SummaryConstructors Constructor Description PostgresTranslator()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringaddForUpdate(String sql)Append FOR UPDATE/FOR UPDATE WITH RS depending on the target DB typebooleanclobSupportsInline()Does the database support inlining for clobsStringcreateGlobalTempTable(String ddl)StringcreateSequence(String name, int cache)Craft the DDL for a CREATE SEQUENCE statementStringcurrentTimestampString()Get the "CURRENT TIMESTAMP" string for the database typeStringdropForeignKeyConstraint(String qualifiedTableName, String constraintName)Generate the DDL for dropping the named FK constraint from the given tableStringdualTableName()The name of the "DUAL" table...that special table giving us one row/column.voidfillProperties(Properties p, ConnectionDetails cd)Configure the properties using information from the ConnectionDetailsStringgetDriverClassName()Get the driver class to use for connectionsDbTypegetType()The main type of the databaseStringgetUrl(Properties connectionProperties)Get the JDBC connection URL based on the propertiesStringglobalTempTableName(String tableName)Get the proper table name based on the type of database we are connected to.booleanisAlreadyExists(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 TYPEbooleanisConnectionError(SQLException x)Returns true if the exception represents a connection errorbooleanisDeadlock(SQLException x)Was this statement the victim of a deadlockbooleanisDerby()Are we working with a Derby databasebooleanisDuplicate(SQLException x)Check the exception to see if it is reporting a duplicate value constraint violationbooleanisDuplicateSchema(SQLException x)booleanisIndexUseSchemaPrefix()Does this database use the schema prefix when defining indexesbooleanisLockTimeout(SQLException x)Database timed out waiting to get a lock.booleanisUndefinedName(SQLException x)Returns true if the SQLException is indicating an object is undefined (e.g.Stringlimit(String arg)Get the correct LIMIT/FETCH NEXT ROWS clause for the databaseStringnextValue(String schemaName, String sequenceName)Statement for getting the next value (for use in a select list or insert values)Stringpagination(int offset, int rowsPerPage)Construct a pagination clause specific to the type of databaseStringreorgTableCommand(String tableName)Return the REORG TABLE command if supported, or null otherwiseStringselectSequenceNextValue(String schemaName, String sequenceName)Compose a select statement to obtain the next value from the named sequenceStringtimestampDiff(String left, String right, String alias)Returns an expression which computes the timestamp difference between left and right in secondsDataAccessExceptiontranslate(SQLException x)Get an appropriate instance of ReplicatorException to throw depending on the details of SQLException
 
- 
- 
- 
Method Detail- 
addForUpdatepublic String addForUpdate(String sql) Description copied from interface:IDatabaseTranslatorAppend FOR UPDATE/FOR UPDATE WITH RS depending on the target DB type- Specified by:
- addForUpdatein interface- IDatabaseTranslator
- Returns:
 
 - 
isDerbypublic boolean isDerby() Description copied from interface:IDatabaseTranslatorAre we working with a Derby database- Specified by:
- isDerbyin interface- IDatabaseTranslator
- Returns:
 
 - 
globalTempTableNamepublic String globalTempTableName(String tableName) Description copied from interface:IDatabaseTranslatorGet the proper table name based on the type of database we are connected to. Derby has its own handling of temp tables- Specified by:
- globalTempTableNamein interface- IDatabaseTranslator
- Returns:
 
 - 
createGlobalTempTablepublic String createGlobalTempTable(String ddl) - Specified by:
- createGlobalTempTablein interface- IDatabaseTranslator
- Returns:
 
 - 
isDuplicatepublic boolean isDuplicate(SQLException x) Description copied from interface:IDatabaseTranslatorCheck the exception to see if it is reporting a duplicate value constraint violation- Specified by:
- isDuplicatein interface- IDatabaseTranslator
- Returns:
 
 - 
isAlreadyExistspublic boolean isAlreadyExists(SQLException x) Description copied from interface:IDatabaseTranslatorCheck 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:
- isAlreadyExistsin interface- IDatabaseTranslator
- Returns:
 
 - 
isLockTimeoutpublic boolean isLockTimeout(SQLException x) Description copied from interface:IDatabaseTranslatorDatabase timed out waiting to get a lock. This is not the same as a deadlock, of course- Specified by:
- isLockTimeoutin interface- IDatabaseTranslator
- Returns:
 
 - 
isIndexUseSchemaPrefixpublic boolean isIndexUseSchemaPrefix() Description copied from interface:IDatabaseTranslatorDoes this database use the schema prefix when defining indexes- Specified by:
- isIndexUseSchemaPrefixin interface- IDatabaseTranslator
- Returns:
 
 - 
isDeadlockpublic boolean isDeadlock(SQLException x) Description copied from interface:IDatabaseTranslatorWas this statement the victim of a deadlock- Specified by:
- isDeadlockin interface- IDatabaseTranslator
- Returns:
 
 - 
isConnectionErrorpublic boolean isConnectionError(SQLException x) Description copied from interface:IDatabaseTranslatorReturns true if the exception represents a connection error- Specified by:
- isConnectionErrorin interface- IDatabaseTranslator
- Returns:
 
 - 
translatepublic DataAccessException translate(SQLException x) Description copied from interface:IDatabaseTranslatorGet an appropriate instance of ReplicatorException to throw depending on the details of SQLException- Specified by:
- translatein interface- IDatabaseTranslator
- Returns:
 
 - 
isDuplicateSchemapublic boolean isDuplicateSchema(SQLException x) 
 - 
isUndefinedNamepublic boolean isUndefinedName(SQLException x) Description copied from interface:IDatabaseTranslatorReturns 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:
- isUndefinedNamein interface- IDatabaseTranslator
- Returns:
 
 - 
fillPropertiespublic void fillProperties(Properties p, ConnectionDetails cd) Description copied from interface:IDatabaseTranslatorConfigure the properties using information from the ConnectionDetails- Specified by:
- fillPropertiesin interface- IDatabaseTranslator
 
 - 
timestampDiffpublic String timestampDiff(String left, String right, String alias) Description copied from interface:IDatabaseTranslatorReturns an expression which computes the timestamp difference between left and right in seconds- Specified by:
- timestampDiffin interface- IDatabaseTranslator
- alias- adds " AS alias " if alias is not null
- Returns:
 
 - 
createSequencepublic String createSequence(String name, int cache) Description copied from interface:IDatabaseTranslatorCraft the DDL for a CREATE SEQUENCE statement- Specified by:
- createSequencein interface- IDatabaseTranslator
- cache- the number of sequence values to cache, if supported by the database
- Returns:
 
 - 
reorgTableCommandpublic String reorgTableCommand(String tableName) Description copied from interface:IDatabaseTranslatorReturn the REORG TABLE command if supported, or null otherwise- Specified by:
- reorgTableCommandin interface- IDatabaseTranslator
- Returns:
 
 - 
getDriverClassNamepublic String getDriverClassName() Description copied from interface:IDatabaseTranslatorGet the driver class to use for connections- Specified by:
- getDriverClassNamein interface- IDatabaseTranslator
- Returns:
 
 - 
getUrlpublic String getUrl(Properties connectionProperties) Description copied from interface:IDatabaseTranslatorGet the JDBC connection URL based on the properties- Specified by:
- getUrlin interface- IDatabaseTranslator
- Returns:
 
 - 
clobSupportsInlinepublic boolean clobSupportsInline() Description copied from interface:IDatabaseTranslatorDoes the database support inlining for clobs- Specified by:
- clobSupportsInlinein interface- IDatabaseTranslator
- Returns:
 
 - 
getTypepublic DbType getType() Description copied from interface:IDatabaseTranslatorThe main type of the database- Specified by:
- getTypein interface- IDatabaseTranslator
- Returns:
 
 - 
dualTableNamepublic String dualTableName() Description copied from interface:IDatabaseTranslatorThe name of the "DUAL" table...that special table giving us one row/column.- Specified by:
- dualTableNamein interface- IDatabaseTranslator
- Returns:
- the name of the "DUAL" table for the database, or null if not supported
 
 - 
selectSequenceNextValuepublic String selectSequenceNextValue(String schemaName, String sequenceName) Description copied from interface:IDatabaseTranslatorCompose a select statement to obtain the next value from the named sequence- Specified by:
- selectSequenceNextValuein interface- IDatabaseTranslator
- Returns:
 
 - 
currentTimestampStringpublic String currentTimestampString() Description copied from interface:IDatabaseTranslatorGet the "CURRENT TIMESTAMP" string for the database type- Specified by:
- currentTimestampStringin interface- IDatabaseTranslator
- Returns:
 
 - 
dropForeignKeyConstraintpublic String dropForeignKeyConstraint(String qualifiedTableName, String constraintName) Description copied from interface:IDatabaseTranslatorGenerate the DDL for dropping the named FK constraint from the given table- Specified by:
- dropForeignKeyConstraintin interface- IDatabaseTranslator
- Parameters:
- qualifiedTableName- such as schema.foo_tab
- constraintName- the constraint name of the FK
- Returns:
 
 - 
nextValuepublic String nextValue(String schemaName, String sequenceName) Description copied from interface:IDatabaseTranslatorStatement for getting the next value (for use in a select list or insert values)- Specified by:
- nextValuein interface- IDatabaseTranslator
- Returns:
 
 - 
limitpublic String limit(String arg) Description copied from interface:IDatabaseTranslatorGet the correct LIMIT/FETCH NEXT ROWS clause for the database- Specified by:
- limitin interface- IDatabaseTranslator
- Parameters:
- arg- a literal int or ? bind-variable marker
- Returns:
 
 - 
paginationpublic String pagination(int offset, int rowsPerPage) Description copied from interface:IDatabaseTranslatorConstruct a pagination clause specific to the type of database- Specified by:
- paginationin interface- IDatabaseTranslator
- Parameters:
- offset- the row offset
- rowsPerPage- limit the number of rows returned (from the offset)
- Returns:
 
 
- 
 
-