Package org.frankframework.dbms
Class GenericDbmsSupport
java.lang.Object
org.frankframework.dbms.GenericDbmsSupport
- All Implemented Interfaces:
IDbmsSupport
- Direct Known Subclasses:
Db2DbmsSupport
,H2DbmsSupport
,MsSqlServerDbmsSupport
,MySqlDbmsSupport
,OracleDbmsSupport
,PostgresqlDbmsSupport
- Author:
- Gerrit van Brakel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected org.apache.logging.log4j.Logger
protected static Map
<String, ISqlTranslator> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyBlobParameter
(PreparedStatement stmt, int column, Object blobInsertHandle) void
applyClobParameter
(PreparedStatement stmt, int column, Object clobHandle) autoIncrementInsertValue
(String sequenceName) boolean
boolean
convertQuery
(String query, String sqlDialectFrom) protected ISqlTranslator
createTranslator
(String source, String target) protected boolean
doHasIndexOnColumns
(Connection conn, String schemaOwner, String tableName, List<String> columns, String indexTableName, String indexColumnTableName, String tableOwnerColumnName, String tableNameColumnName, String indexNameColumnName, String columnNameColumnName, String columPositionColumnName) protected boolean
doIsColumnPresent
(Connection conn, String columnsTable, String schemaColumn, String tableNameColumn, String columnNameColumn, String schemaName, String tableName, String columnName) Alternative implementation of isColumnPresent(), that can be used by descender classes if the implementation via metadata does not work for that driver.protected boolean
doIsTablePresent
(Connection conn, String tablesTable, String schemaColumn, String tableNameColumn, String schemaName, String tableName) Alternative implementation of isTablePresent(), that can be used by descender classes if the implementation via metadata does not work for that driver.getBlobHandle
(PreparedStatement stmt, int column) getBlobHandle
(ResultSet rs, int column) getBlobInputStream
(ResultSet rs, int column) getBlobInputStream
(ResultSet rs, String column) getBlobOutputStream
(PreparedStatement stmt, int column, Object blobInsertHandle) getBlobOutputStream
(ResultSet rs, int column, Object blobUpdateHandle) protected OutputStream
getBlobOutputStream
(ResultSet rs, Object blobUpdateHandle) getBooleanValue
(boolean value) getClobHandle
(PreparedStatement stmt, int column) getClobHandle
(ResultSet rs, int column) getClobReader
(ResultSet rs, int column) getClobReader
(ResultSet rs, String column) getClobWriter
(PreparedStatement stmt, int column, Object clobHandle) getClobWriter
(ResultSet rs, int column, Object clobHandle) getDateAndOffset
(String dateValue, int daysOffset) getDatetimeLiteral
(Date date) getDbms()
protected String
getFormattedDate
(Date date) http://en.wikipedia.org/wiki/DUAL_tablegetSchema
(Connection conn) protected ISqlTranslator
getSqlTranslator
(String sqlDialectFrom) SQL String returning current date and time of dbms.getTableColumns
(Connection conn, String tableName) getTableColumns
(Connection conn, String schemaName, String tableName) getTableColumns
(Connection conn, String schemaName, String tableName, String columnNamePattern) getTimestampAsDate
(String columnName) boolean
hasIndexOnColumn
(Connection conn, String schemaName, String tableName, String columnName) boolean
hasIndexOnColumns
(Connection conn, String schemaOwner, String tableName, List<String> columns) boolean
boolean
isBlobType
(ResultSetMetaData rsmeta, int colNum) boolean
isClobType
(ResultSetMetaData rsmeta, int colNum) boolean
isColumnPresent
(Connection conn, String tableName, String columnName) boolean
isColumnPresent
(Connection conn, String schemaName, String tableName, String columnName) boolean
boolean
protected boolean
isQueryConversionRequired
(String sqlDialectFrom) boolean
isSequencePresent
(Connection conn, String schemaOwner, String tableName, String sequenceName) boolean
isTablePresent
(Connection conn, String tableName) boolean
isTablePresent
(Connection conn, String schemaName, String tableName) prepareQueryTextForNonLockingRead
(String selectQuery) Modify the provided selectQuery in such a way that the resulting query will not be blocked by locks, and will avoid placing locks itself as much as possible.prepareQueryTextForWorkQueuePeeking
(int batchSize, String selectQuery) prepareQueryTextForWorkQueuePeeking
(int batchSize, String selectQuery, int wait) prepareQueryTextForWorkQueueReading
(int batchSize, String selectQuery) prepareQueryTextForWorkQueueReading
(int batchSize, String selectQuery, int wait) provideFirstRowsHintAfterFirstKeyword
(int rowCount) provideIndexHintAfterFirstKeyword
(String tableName, String indexName) provideTrailingFirstRowsHint
(int rowCount) splitQuery
(String query) void
updateBlob
(ResultSet rs, int column, Object blobUpdateHandle) void
updateBlob
(ResultSet rs, String column, Object blobUpdateHandle) void
updateClob
(ResultSet rs, int column, Object clobHandle) void
updateClob
(ResultSet rs, String column, Object clobHandle) protected void
warnConvertQuery
(String sqlDialectFrom) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.frankframework.dbms.IDbmsSupport
canFetchStatementParameterMetaData, getCursorSqlType, isRowVersionTimestamp, isStoredProcedureResultSetSupported
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log -
KEYWORD_SELECT
- See Also:
-
sqlTranslators
-
-
Constructor Details
-
GenericDbmsSupport
public GenericDbmsSupport()
-
-
Method Details
-
getDbmsName
- Specified by:
getDbmsName
in interfaceIDbmsSupport
-
getDbms
- Specified by:
getDbms
in interfaceIDbmsSupport
-
isParameterTypeMatchRequired
public boolean isParameterTypeMatchRequired()- Specified by:
isParameterTypeMatchRequired
in interfaceIDbmsSupport
-
hasSkipLockedFunctionality
public boolean hasSkipLockedFunctionality()- Specified by:
hasSkipLockedFunctionality
in interfaceIDbmsSupport
-
getSysDate
Description copied from interface:IDbmsSupport
SQL String returning current date and time of dbms.- Specified by:
getSysDate
in interfaceIDbmsSupport
-
getDateAndOffset
- Specified by:
getDateAndOffset
in interfaceIDbmsSupport
-
getFromForTablelessSelect
Description copied from interface:IDbmsSupport
http://en.wikipedia.org/wiki/DUAL_table- Specified by:
getFromForTablelessSelect
in interfaceIDbmsSupport
-
getAutoIncrementKeyFieldType
- Specified by:
getAutoIncrementKeyFieldType
in interfaceIDbmsSupport
-
autoIncrementKeyMustBeInserted
public boolean autoIncrementKeyMustBeInserted()- Specified by:
autoIncrementKeyMustBeInserted
in interfaceIDbmsSupport
-
autoIncrementInsertValue
- Specified by:
autoIncrementInsertValue
in interfaceIDbmsSupport
-
autoIncrementUsesSequenceObject
public boolean autoIncrementUsesSequenceObject()- Specified by:
autoIncrementUsesSequenceObject
in interfaceIDbmsSupport
-
getTimestampFieldType
- Specified by:
getTimestampFieldType
in interfaceIDbmsSupport
-
getDatetimeLiteral
- Specified by:
getDatetimeLiteral
in interfaceIDbmsSupport
-
getFormattedDate
-
getTimestampAsDate
- Specified by:
getTimestampAsDate
in interfaceIDbmsSupport
-
isClobType
- Specified by:
isClobType
in interfaceIDbmsSupport
- Throws:
SQLException
-
getClobHandle
- Specified by:
getClobHandle
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
getClobWriter
- Specified by:
getClobWriter
in interfaceIDbmsSupport
- Throws:
SQLException
-
updateClob
public void updateClob(ResultSet rs, int column, Object clobHandle) throws SQLException, DbmsException - Specified by:
updateClob
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
updateClob
public void updateClob(ResultSet rs, String column, Object clobHandle) throws SQLException, DbmsException - Specified by:
updateClob
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
getClobHandle
- Specified by:
getClobHandle
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
getClobWriter
public Writer getClobWriter(PreparedStatement stmt, int column, Object clobHandle) throws SQLException - Specified by:
getClobWriter
in interfaceIDbmsSupport
- Throws:
SQLException
-
applyClobParameter
public void applyClobParameter(PreparedStatement stmt, int column, Object clobHandle) throws SQLException - Specified by:
applyClobParameter
in interfaceIDbmsSupport
- Throws:
SQLException
-
getClobReader
- Specified by:
getClobReader
in interfaceIDbmsSupport
- Throws:
SQLException
-
getClobReader
- Specified by:
getClobReader
in interfaceIDbmsSupport
- Throws:
SQLException
-
getBlobFieldType
- Specified by:
getBlobFieldType
in interfaceIDbmsSupport
-
isBlobType
- Specified by:
isBlobType
in interfaceIDbmsSupport
- Throws:
SQLException
-
getBlobHandle
- Specified by:
getBlobHandle
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
getBlobOutputStream
protected OutputStream getBlobOutputStream(ResultSet rs, Object blobUpdateHandle) throws SQLException - Throws:
SQLException
-
getBlobOutputStream
public OutputStream getBlobOutputStream(ResultSet rs, int column, Object blobUpdateHandle) throws SQLException, DbmsException - Specified by:
getBlobOutputStream
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
updateBlob
public void updateBlob(ResultSet rs, int column, Object blobUpdateHandle) throws SQLException, DbmsException - Specified by:
updateBlob
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
updateBlob
public void updateBlob(ResultSet rs, String column, Object blobUpdateHandle) throws SQLException, DbmsException - Specified by:
updateBlob
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
getBlobHandle
- Specified by:
getBlobHandle
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
getBlobOutputStream
public OutputStream getBlobOutputStream(PreparedStatement stmt, int column, Object blobInsertHandle) throws SQLException - Specified by:
getBlobOutputStream
in interfaceIDbmsSupport
- Throws:
SQLException
-
applyBlobParameter
public void applyBlobParameter(PreparedStatement stmt, int column, Object blobInsertHandle) throws SQLException - Specified by:
applyBlobParameter
in interfaceIDbmsSupport
- Throws:
SQLException
-
getBlobInputStream
- Specified by:
getBlobInputStream
in interfaceIDbmsSupport
- Throws:
SQLException
-
getBlobInputStream
- Specified by:
getBlobInputStream
in interfaceIDbmsSupport
- Throws:
SQLException
-
getTextFieldType
- Specified by:
getTextFieldType
in interfaceIDbmsSupport
-
prepareQueryTextForWorkQueueReading
public String prepareQueryTextForWorkQueueReading(int batchSize, String selectQuery) throws DbmsException - Specified by:
prepareQueryTextForWorkQueueReading
in interfaceIDbmsSupport
- Throws:
DbmsException
-
prepareQueryTextForWorkQueueReading
public String prepareQueryTextForWorkQueueReading(int batchSize, String selectQuery, int wait) throws DbmsException - Specified by:
prepareQueryTextForWorkQueueReading
in interfaceIDbmsSupport
- Throws:
DbmsException
-
prepareQueryTextForWorkQueuePeeking
public String prepareQueryTextForWorkQueuePeeking(int batchSize, String selectQuery) throws DbmsException - Specified by:
prepareQueryTextForWorkQueuePeeking
in interfaceIDbmsSupport
- Throws:
DbmsException
-
prepareQueryTextForWorkQueuePeeking
public String prepareQueryTextForWorkQueuePeeking(int batchSize, String selectQuery, int wait) throws DbmsException - Specified by:
prepareQueryTextForWorkQueuePeeking
in interfaceIDbmsSupport
- Throws:
DbmsException
-
prepareQueryTextForNonLockingRead
Description copied from interface:IDbmsSupport
Modify the provided selectQuery in such a way that the resulting query will not be blocked by locks, and will avoid placing locks itself as much as possible. Preferably, the effective isolation level is READ_COMMITTED (committed rows of other transactions may be read), but if placing locks can be avoided by an isolation level similar to READ_UNCOMMITTED, that is allowed too. Should return the query unmodified if no special action is required. For an example, seeMsSqlServerDbmsSupport.prepareQueryTextForNonLockingRead(String)
- Specified by:
prepareQueryTextForNonLockingRead
in interfaceIDbmsSupport
- Throws:
DbmsException
-
provideIndexHintAfterFirstKeyword
- Specified by:
provideIndexHintAfterFirstKeyword
in interfaceIDbmsSupport
-
provideFirstRowsHintAfterFirstKeyword
- Specified by:
provideFirstRowsHintAfterFirstKeyword
in interfaceIDbmsSupport
-
provideTrailingFirstRowsHint
- Specified by:
provideTrailingFirstRowsHint
in interfaceIDbmsSupport
-
getSchema
- Specified by:
getSchema
in interfaceIDbmsSupport
- Throws:
DbmsException
-
getTableColumns
- Specified by:
getTableColumns
in interfaceIDbmsSupport
- Throws:
DbmsException
-
getTableColumns
public ResultSet getTableColumns(Connection conn, String schemaName, String tableName) throws DbmsException - Specified by:
getTableColumns
in interfaceIDbmsSupport
- Throws:
DbmsException
-
getTableColumns
public ResultSet getTableColumns(Connection conn, String schemaName, String tableName, String columnNamePattern) throws DbmsException - Specified by:
getTableColumns
in interfaceIDbmsSupport
- Throws:
DbmsException
-
isTablePresent
- Specified by:
isTablePresent
in interfaceIDbmsSupport
- Throws:
DbmsException
-
isTablePresent
public boolean isTablePresent(Connection conn, String schemaName, String tableName) throws DbmsException - Specified by:
isTablePresent
in interfaceIDbmsSupport
- Throws:
DbmsException
-
isColumnPresent
public boolean isColumnPresent(Connection conn, String tableName, String columnName) throws DbmsException - Specified by:
isColumnPresent
in interfaceIDbmsSupport
- Throws:
DbmsException
-
isColumnPresent
public boolean isColumnPresent(Connection conn, String schemaName, String tableName, String columnName) throws DbmsException - Specified by:
isColumnPresent
in interfaceIDbmsSupport
- Throws:
DbmsException
-
hasIndexOnColumn
public boolean hasIndexOnColumn(Connection conn, String schemaName, String tableName, String columnName) throws DbmsException - Specified by:
hasIndexOnColumn
in interfaceIDbmsSupport
- Throws:
DbmsException
-
doHasIndexOnColumns
protected boolean doHasIndexOnColumns(Connection conn, String schemaOwner, String tableName, List<String> columns, String indexTableName, String indexColumnTableName, String tableOwnerColumnName, String tableNameColumnName, String indexNameColumnName, String columnNameColumnName, String columPositionColumnName) -
doIsTablePresent
protected boolean doIsTablePresent(Connection conn, String tablesTable, String schemaColumn, String tableNameColumn, String schemaName, String tableName) throws DbmsException Alternative implementation of isTablePresent(), that can be used by descender classes if the implementation via metadata does not work for that driver.- Throws:
DbmsException
-
doIsColumnPresent
protected boolean doIsColumnPresent(Connection conn, String columnsTable, String schemaColumn, String tableNameColumn, String columnNameColumn, String schemaName, String tableName, String columnName) throws DbmsException Alternative implementation of isColumnPresent(), that can be used by descender classes if the implementation via metadata does not work for that driver.- Throws:
DbmsException
-
isSequencePresent
public boolean isSequencePresent(Connection conn, String schemaOwner, String tableName, String sequenceName) - Specified by:
isSequencePresent
in interfaceIDbmsSupport
-
hasIndexOnColumns
public boolean hasIndexOnColumns(Connection conn, String schemaOwner, String tableName, List<String> columns) throws DbmsException - Specified by:
hasIndexOnColumns
in interfaceIDbmsSupport
- Throws:
DbmsException
-
isConstraintViolation
- Specified by:
isConstraintViolation
in interfaceIDbmsSupport
-
getLength
- Specified by:
getLength
in interfaceIDbmsSupport
-
getBooleanValue
- Specified by:
getBooleanValue
in interfaceIDbmsSupport
-
createTranslator
- Throws:
DbmsException
-
getSqlTranslator
@Nullable protected ISqlTranslator getSqlTranslator(@Nonnull String sqlDialectFrom) throws DbmsException - Throws:
DbmsException
-
convertQuery
@Nonnull public String convertQuery(@Nonnull String query, @Nonnull String sqlDialectFrom) throws SQLException, DbmsException - Specified by:
convertQuery
in interfaceIDbmsSupport
- Throws:
SQLException
DbmsException
-
warnConvertQuery
-
isQueryConversionRequired
-
splitQuery
-