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 Stringprotected org.apache.logging.log4j.Loggerprotected static Map<String, ISqlTranslator> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyBlobParameter(PreparedStatement stmt, int column, Object blobInsertHandle) voidapplyClobParameter(PreparedStatement stmt, int column, Object clobHandle) autoIncrementInsertValue(String sequenceName) booleanbooleanconvertQuery(String query, String sqlDialectFrom) protected ISqlTranslatorcreateTranslator(String source, String target) protected booleandoHasIndexOnColumns(Connection conn, String schemaOwner, String tableName, List<String> columns, String indexTableName, String indexColumnTableName, String tableOwnerColumnName, String tableNameColumnName, String indexNameColumnName, String columnNameColumnName, String columPositionColumnName) protected booleandoIsColumnPresent(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 booleandoIsTablePresent(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 OutputStreamgetBlobOutputStream(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 StringgetFormattedDate(Date date) http://en.wikipedia.org/wiki/DUAL_tablegetSchema(Connection conn) protected ISqlTranslatorgetSqlTranslator(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) booleanhasIndexOnColumn(Connection conn, String schemaName, String tableName, String columnName) booleanhasIndexOnColumns(Connection conn, String schemaOwner, String tableName, List<String> columns) booleanbooleanisBlobType(ResultSetMetaData rsmeta, int colNum) booleanisClobType(ResultSetMetaData rsmeta, int colNum) booleanisColumnPresent(Connection conn, String tableName, String columnName) booleanisColumnPresent(Connection conn, String schemaName, String tableName, String columnName) booleanbooleanprotected booleanisQueryConversionRequired(String sqlDialectFrom) booleanisSequencePresent(Connection conn, String schemaOwner, String tableName, String sequenceName) booleanisTablePresent(Connection conn, String tableName) booleanisTablePresent(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) voidupdateBlob(ResultSet rs, int column, Object blobUpdateHandle) voidupdateBlob(ResultSet rs, String column, Object blobUpdateHandle) voidupdateClob(ResultSet rs, int column, Object clobHandle) voidupdateClob(ResultSet rs, String column, Object clobHandle) protected voidwarnConvertQuery(String sqlDialectFrom) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.frankframework.dbms.IDbmsSupport
canFetchStatementParameterMetaData, getCursorSqlType, getDbmsName, isRowVersionTimestamp, isStoredProcedureResultSetSupported
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log -
KEYWORD_SELECT
- See Also:
-
sqlTranslators
-
-
Constructor Details
-
GenericDbmsSupport
public GenericDbmsSupport()
-
-
Method Details
-
getDbms
- Specified by:
getDbmsin interfaceIDbmsSupport
-
isParameterTypeMatchRequired
public boolean isParameterTypeMatchRequired()- Specified by:
isParameterTypeMatchRequiredin interfaceIDbmsSupport
-
hasSkipLockedFunctionality
public boolean hasSkipLockedFunctionality()- Specified by:
hasSkipLockedFunctionalityin interfaceIDbmsSupport
-
getSysDate
Description copied from interface:IDbmsSupportSQL String returning current date and time of dbms.- Specified by:
getSysDatein interfaceIDbmsSupport
-
getDateAndOffset
- Specified by:
getDateAndOffsetin interfaceIDbmsSupport
-
getFromForTablelessSelect
Description copied from interface:IDbmsSupporthttp://en.wikipedia.org/wiki/DUAL_table- Specified by:
getFromForTablelessSelectin interfaceIDbmsSupport
-
getAutoIncrementKeyFieldType
- Specified by:
getAutoIncrementKeyFieldTypein interfaceIDbmsSupport
-
autoIncrementKeyMustBeInserted
public boolean autoIncrementKeyMustBeInserted()- Specified by:
autoIncrementKeyMustBeInsertedin interfaceIDbmsSupport
-
autoIncrementInsertValue
- Specified by:
autoIncrementInsertValuein interfaceIDbmsSupport
-
autoIncrementUsesSequenceObject
public boolean autoIncrementUsesSequenceObject()- Specified by:
autoIncrementUsesSequenceObjectin interfaceIDbmsSupport
-
getTimestampFieldType
- Specified by:
getTimestampFieldTypein interfaceIDbmsSupport
-
getDatetimeLiteral
- Specified by:
getDatetimeLiteralin interfaceIDbmsSupport
-
getFormattedDate
-
getTimestampAsDate
- Specified by:
getTimestampAsDatein interfaceIDbmsSupport
-
isClobType
- Specified by:
isClobTypein interfaceIDbmsSupport- Throws:
SQLException
-
getClobHandle
- Specified by:
getClobHandlein interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
getClobWriter
- Specified by:
getClobWriterin interfaceIDbmsSupport- Throws:
SQLException
-
updateClob
public void updateClob(ResultSet rs, int column, Object clobHandle) throws SQLException, DbmsException - Specified by:
updateClobin interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
updateClob
public void updateClob(ResultSet rs, String column, Object clobHandle) throws SQLException, DbmsException - Specified by:
updateClobin interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
getClobHandle
- Specified by:
getClobHandlein interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
getClobWriter
public Writer getClobWriter(PreparedStatement stmt, int column, Object clobHandle) throws SQLException - Specified by:
getClobWriterin interfaceIDbmsSupport- Throws:
SQLException
-
applyClobParameter
public void applyClobParameter(PreparedStatement stmt, int column, Object clobHandle) throws SQLException - Specified by:
applyClobParameterin interfaceIDbmsSupport- Throws:
SQLException
-
getClobReader
- Specified by:
getClobReaderin interfaceIDbmsSupport- Throws:
SQLException
-
getClobReader
- Specified by:
getClobReaderin interfaceIDbmsSupport- Throws:
SQLException
-
getBlobFieldType
- Specified by:
getBlobFieldTypein interfaceIDbmsSupport
-
isBlobType
- Specified by:
isBlobTypein interfaceIDbmsSupport- Throws:
SQLException
-
getBlobHandle
- Specified by:
getBlobHandlein interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
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:
getBlobOutputStreamin interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
updateBlob
public void updateBlob(ResultSet rs, int column, Object blobUpdateHandle) throws SQLException, DbmsException - Specified by:
updateBlobin interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
updateBlob
public void updateBlob(ResultSet rs, String column, Object blobUpdateHandle) throws SQLException, DbmsException - Specified by:
updateBlobin interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
getBlobHandle
- Specified by:
getBlobHandlein interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
getBlobOutputStream
public OutputStream getBlobOutputStream(PreparedStatement stmt, int column, Object blobInsertHandle) throws SQLException - Specified by:
getBlobOutputStreamin interfaceIDbmsSupport- Throws:
SQLException
-
applyBlobParameter
public void applyBlobParameter(PreparedStatement stmt, int column, Object blobInsertHandle) throws SQLException - Specified by:
applyBlobParameterin interfaceIDbmsSupport- Throws:
SQLException
-
getBlobInputStream
- Specified by:
getBlobInputStreamin interfaceIDbmsSupport- Throws:
SQLException
-
getBlobInputStream
- Specified by:
getBlobInputStreamin interfaceIDbmsSupport- Throws:
SQLException
-
getTextFieldType
- Specified by:
getTextFieldTypein interfaceIDbmsSupport
-
prepareQueryTextForWorkQueueReading
public String prepareQueryTextForWorkQueueReading(int batchSize, String selectQuery) throws DbmsException - Specified by:
prepareQueryTextForWorkQueueReadingin interfaceIDbmsSupport- Throws:
DbmsException
-
prepareQueryTextForWorkQueueReading
public String prepareQueryTextForWorkQueueReading(int batchSize, String selectQuery, int wait) throws DbmsException - Specified by:
prepareQueryTextForWorkQueueReadingin interfaceIDbmsSupport- Throws:
DbmsException
-
prepareQueryTextForWorkQueuePeeking
public String prepareQueryTextForWorkQueuePeeking(int batchSize, String selectQuery) throws DbmsException - Specified by:
prepareQueryTextForWorkQueuePeekingin interfaceIDbmsSupport- Throws:
DbmsException
-
prepareQueryTextForWorkQueuePeeking
public String prepareQueryTextForWorkQueuePeeking(int batchSize, String selectQuery, int wait) throws DbmsException - Specified by:
prepareQueryTextForWorkQueuePeekingin interfaceIDbmsSupport- Throws:
DbmsException
-
prepareQueryTextForNonLockingRead
Description copied from interface:IDbmsSupportModify 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:
prepareQueryTextForNonLockingReadin interfaceIDbmsSupport- Throws:
DbmsException
-
provideIndexHintAfterFirstKeyword
- Specified by:
provideIndexHintAfterFirstKeywordin interfaceIDbmsSupport
-
provideFirstRowsHintAfterFirstKeyword
- Specified by:
provideFirstRowsHintAfterFirstKeywordin interfaceIDbmsSupport
-
provideTrailingFirstRowsHint
- Specified by:
provideTrailingFirstRowsHintin interfaceIDbmsSupport
-
getSchema
- Specified by:
getSchemain interfaceIDbmsSupport- Throws:
DbmsException
-
getTableColumns
- Specified by:
getTableColumnsin interfaceIDbmsSupport- Throws:
DbmsException
-
getTableColumns
public ResultSet getTableColumns(Connection conn, String schemaName, String tableName) throws DbmsException - Specified by:
getTableColumnsin interfaceIDbmsSupport- Throws:
DbmsException
-
getTableColumns
public ResultSet getTableColumns(Connection conn, String schemaName, String tableName, String columnNamePattern) throws DbmsException - Specified by:
getTableColumnsin interfaceIDbmsSupport- Throws:
DbmsException
-
isTablePresent
- Specified by:
isTablePresentin interfaceIDbmsSupport- Throws:
DbmsException
-
isTablePresent
public boolean isTablePresent(Connection conn, String schemaName, String tableName) throws DbmsException - Specified by:
isTablePresentin interfaceIDbmsSupport- Throws:
DbmsException
-
isColumnPresent
public boolean isColumnPresent(Connection conn, String tableName, String columnName) throws DbmsException - Specified by:
isColumnPresentin interfaceIDbmsSupport- Throws:
DbmsException
-
isColumnPresent
public boolean isColumnPresent(Connection conn, String schemaName, String tableName, String columnName) throws DbmsException - Specified by:
isColumnPresentin interfaceIDbmsSupport- Throws:
DbmsException
-
hasIndexOnColumn
public boolean hasIndexOnColumn(Connection conn, String schemaName, String tableName, String columnName) throws DbmsException - Specified by:
hasIndexOnColumnin 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:
isSequencePresentin interfaceIDbmsSupport
-
hasIndexOnColumns
public boolean hasIndexOnColumns(Connection conn, String schemaOwner, String tableName, List<String> columns) throws DbmsException - Specified by:
hasIndexOnColumnsin interfaceIDbmsSupport- Throws:
DbmsException
-
isConstraintViolation
- Specified by:
isConstraintViolationin interfaceIDbmsSupport
-
getLength
- Specified by:
getLengthin interfaceIDbmsSupport
-
getBooleanValue
- Specified by:
getBooleanValuein 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:
convertQueryin interfaceIDbmsSupport- Throws:
SQLExceptionDbmsException
-
warnConvertQuery
-
isQueryConversionRequired
-
splitQuery
-