Package org.pentaho.di.core.database
Class GenericDatabaseMeta
- java.lang.Object
-
- org.pentaho.di.core.database.BaseDatabaseMeta
-
- org.pentaho.di.core.database.GenericDatabaseMeta
-
- All Implemented Interfaces:
Cloneable
,DatabaseInterface
,DatabaseInterfaceExtended
- Direct Known Subclasses:
RemedyActionRequestSystemDatabaseMeta
public class GenericDatabaseMeta extends BaseDatabaseMeta implements DatabaseInterface
Contains Generic Database Connection information through static final members- Since:
- 11-mrt-2005
- Author:
- Matt
-
-
Field Summary
Fields Modifier and Type Field Description static String
ATRRIBUTE_CUSTOM_DRIVER_CLASS
static String
ATRRIBUTE_CUSTOM_URL
static String
DATABASE_DIALECT_ID
-
Fields inherited from class org.pentaho.di.core.database.BaseDatabaseMeta
ATTRIBUTE_CLUSTER_DBNAME_PREFIX, ATTRIBUTE_CLUSTER_HOSTNAME_PREFIX, ATTRIBUTE_CLUSTER_PASSWORD_PREFIX, ATTRIBUTE_CLUSTER_PORT_PREFIX, ATTRIBUTE_CLUSTER_USERNAME_PREFIX, ATTRIBUTE_FORCE_IDENTIFIERS_TO_LOWERCASE, ATTRIBUTE_FORCE_IDENTIFIERS_TO_UPPERCASE, ATTRIBUTE_INITIAL_POOL_SIZE, ATTRIBUTE_IS_CLUSTERED, ATTRIBUTE_MAXIMUM_POOL_SIZE, ATTRIBUTE_MSSQL_DOUBLE_DECIMAL_SEPARATOR, ATTRIBUTE_POOLING_PARAMETER_PREFIX, ATTRIBUTE_PORT_NUMBER, ATTRIBUTE_PREFERRED_SCHEMA_NAME, ATTRIBUTE_PREFIX_EXTRA_OPTION, ATTRIBUTE_PRESERVE_RESERVED_WORD_CASE, ATTRIBUTE_QUOTE_ALL_FIELDS, ATTRIBUTE_SQL_CONNECT, ATTRIBUTE_SUPPORTS_BOOLEAN_DATA_TYPE, ATTRIBUTE_SUPPORTS_TIMESTAMP_DATA_TYPE, ATTRIBUTE_USE_POOLING, ATTRIBUTE_USE_RESULT_STREAMING, AUTOINCREMENT_SQL_FOR_BATCH_ID, NAMED_CLUSTER_ID, poolingParameters, releaseSavepoint, SELECT_COUNT_STATEMENT, SEQUENCE_FOR_BATCH_ID
-
-
Constructor Summary
Constructors Constructor Description GenericDatabaseMeta()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(String attributeId, String value)
Add extra attribute on this connectionvoid
addExtraOption(String databaseTypeCode, String option, String value)
Add an extra option to the attributes listValueMetaInterface
customizeValueFromSQLType(ValueMetaInterface v, ResultSetMetaData rm, int index)
Customizes the ValueMetaInterface defined in the baseString
generateColumnAlias(int columnIndex, String suggestedName)
Generate a column alias given the column index and suggested name.int[]
getAccessTypeList()
Get the list of possible access types for a database.String
getAddColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean useAutoinc, String pk, boolean semicolon)
Generates the SQL statement to add a column to the specified table For this generic type, i set it to the most common possibility.String
getCreateTableStatement()
Customizes the ValueMetaInterface defined in the baseString
getDatabaseDialect()
protected DatabaseInterface
getDatabaseDialectInternal()
Map<String,String>
getDefaultOptions()
String
getDriverClass()
Obtain the name of the JDBC driver class that we need to use!String
getDropColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean useAutoinc, String pk, boolean semicolon)
Generates the SQL statement to drop a column from the specified tableString
getEndQuote()
String
getExtraOptionIndicator()
Map<String,String>
getExtraOptions()
String
getExtraOptionSeparator()
String
getExtraOptionsHelpText()
String
getExtraOptionValueSeparator()
String
getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean useAutoinc, boolean addFieldName, boolean addCr)
Describe a Value as a field in the database.String
getFunctionAverage()
String
getFunctionCount()
String
getFunctionMaximum()
String
getFunctionMinimum()
String
getFunctionSum()
String
getLimitClause(int nrRows)
int
getMaxColumnsInIndex()
int
getMaxTextFieldLength()
Get the maximum length of a text field for this database connection.int
getMaxVARCHARLength()
Get the maximum length of a text field (VARCHAR) for this database connection.String
getModifyColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean useAutoinc, String pk, boolean semicolon)
Generates the SQL statement to modify a column in the specified tableint
getNotFoundTK(boolean useAutoinc)
Get the not found technical key.String[]
getReservedWords()
String
getSafeFieldname(String fieldName)
Sanitize a string for usage as a field name Append an underscore to any field name that matches a reserved word Replaces spaces with underscores Prefixes a string with underscore that begins with a numberString
getSchemaTableCombination(String schemaName, String tablePart)
Get the schema-table combination to query the right table.String
getSelectCountStatement(String tableName)
Build the SQL to count the number of rows in the passed table.String
getSequenceNoMaxValueOption()
String
getSQLColumnExists(String columnname, String tablename)
String
getSQLInsertAutoIncUnknownDimensionRow(String schemaTable, String keyField, String versionField)
Get the SQL to insert a new empty unknown record in a dimension.String
getSQLListOfSchemas()
String
getSQLLockTables(String[] tableNames)
String
getSQLQueryFields(String tableName)
Returns the minimal SQL to launch in order to determine the layout of the resultset for a given database tableString
getSQLTableExists(String tableName)
String
getSQLUnlockTables(String[] tableName)
String
getSQLValue(ValueMetaInterface valueMeta, Object valueData, String dateFormat)
Convert a value in the SQL equivalent.String
getStartQuote()
String[]
getSynonymTypes()
String[]
getTableTypes()
String
getTruncateTableStatement(String tableName)
String
getURL(String hostname, String port, String databaseName)
String[]
getUsedLibraries()
String[]
getViewTypes()
boolean
isDefaultingToUppercase()
boolean
isDisplaySizeTwiceThePrecision()
boolean
isExplorable()
boolean
isFetchSizeSupported()
Checks whether or not the command setFetchSize() is supported by the JDBC driver...boolean
isForcingIdentifiersToLowerCase()
boolean
isForcingIdentifiersToUpperCase()
boolean
isMySQLVariant()
boolean
isQuoteAllFields()
boolean
isStreamingResults()
boolean
isSystemTable(String tableName)
boolean
isUsingDoubleDecimalAsSchemaTableSeparator()
boolean
needsToLockAllTables()
boolean
preserveReservedCase()
boolean
quoteReservedWords()
String
quoteSQLString(String string)
Adds quotes around the string according to the database dialect and also escapes special characters like CR, LF and the quote character itself.boolean
requiresCastToVariousForIsNull()
boolean
requiresCreateTablePrimaryKeyAppend()
protected void
resolveDialect(String dialectName)
void
setDatabaseDialect(String databaseDialect)
void
setForcingIdentifiersToLowerCase(boolean forceUpperCase)
void
setForcingIdentifiersToUpperCase(boolean forceUpperCase)
void
setPreserveReservedCase(boolean b)
void
setQuoteAllFields(boolean quoteAllFields)
void
setStreamingResults(boolean useStreaming)
void
setSupportsBooleanDataType(boolean b)
void
setSupportsTimestampDataType(boolean b)
void
setUsingDoubleDecimalAsSchemaTableSeparator(boolean useDoubleDecimalSeparator)
boolean
supportsAutoGeneratedKeys()
boolean
supportsBatchUpdates()
boolean
supportsBitmapIndex()
boolean
supportsBooleanDataType()
boolean
supportsFloatRoundingOnUpdate()
Most databases round number(7,2) 17.29999999 to 17.30, but some don't.boolean
supportsGetBlob()
boolean
supportsNewLinesInSQL()
boolean
supportsOptionsInURL()
boolean
supportsPreparedStatementMetadataRetrieval()
Most databases allow you to retrieve result metadata by preparing a SELECT statement.boolean
supportsResultSetMetadataRetrievalOnly()
boolean
supportsSequenceNoMaxValueOption()
boolean
supportsSetMaxRows()
boolean
supportsSynonyms()
boolean
supportsTimestampDataType()
boolean
supportsTimeStampToDateConversion()
boolean
supportsViews()
boolean
useSchemaNameForTableList()
-
Methods inherited from class org.pentaho.di.core.database.BaseDatabaseMeta
addDefaultOptions, canTest, checkIndexExists, clone, fullExceptionLog, getAccessType, getAttribute, getAttributes, getBackwardsCompatibleSchemaTableCombination, getBackwardsCompatibleTable, getConnectionPoolingProperties, getConnectSQL, getDatabaseFactoryName, getDatabaseName, getDatabasePortNumberString, getDataTablespace, getDataTablespaceDDL, getDefaultDatabasePort, getDisplayName, getDropTableIfExistsStatement, getFieldnameProtector, getHostname, getIndexTablespace, getIndexTablespaceDDL, getInitialPoolSize, getInitialPoolSizeString, getMaximumPoolSize, getMaximumPoolSizeString, getName, getNamedCluster, getNextBatchId, getNextBatchIdUsingAutoIncSQL, getNextBatchIdUsingLockTables, getNextBatchIdUsingSequence, getObjectId, getPartitioningInformation, getPassword, getPluginId, getPluginName, getPreferredSchemaName, getServername, getSQLCurrentSequenceValue, getSQLListOfProcedures, getSQLListOfSequences, getSQLNextSequenceValue, getSqlScriptStatements, getSQLSequenceExists, getTablespaceDDL, getUsername, getValueFromResultSet, getXulOverlayFile, isChanged, isPartitioned, isRequiringTransactionsOnQueries, isUsingConnectionPool, needsPlaceHolder, onlySpaces, parseStatements, releaseSavepoint, requiresName, setAccessType, setAttributes, setChanged, setConnectionPoolingProperties, setConnectSQL, setDatabaseName, setDatabasePortNumberString, setDataTablespace, setDisplayName, setHostname, setIndexTablespace, setInitialPoolSize, setInitialPoolSizeString, setMaximumPoolSize, setMaximumPoolSizeString, setName, setNamedCluster, setObjectId, setPartitioned, setPartitioningInformation, setPassword, setPluginId, setPluginName, setPreferredSchemaName, setServername, setUsername, setUsingConnectionPool, supportsAutoInc, supportsCatalogs, supportsEmptyTransactions, supportsErrorHandling, supportsErrorHandlingOnBatchUpdates, supportsRepository, supportsSchemas, supportsSequences, supportsSetCharacterStream, supportsSetLong, supportsTransactions, useSafePoints
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pentaho.di.core.database.DatabaseInterface
addDefaultOptions, checkIndexExists, clone, createSqlScriptParser, getAccessType, getAttribute, getAttributes, getConnectionPoolingProperties, getConnectSQL, getDatabaseFactoryName, getDatabaseName, getDatabasePortNumberString, getDataTablespace, getDataTablespaceDDL, getDefaultDatabasePort, getDisplayName, getHostname, getIndexTablespace, getIndexTablespaceDDL, getInitialPoolSize, getInitialPoolSizeString, getLegacyColumnName, getMaximumPoolSize, getMaximumPoolSizeString, getName, getNamedCluster, getNamedClusterList, getNextBatchId, getObjectId, getPartitioningInformation, getPassword, getPluginId, getPluginName, getPreferredSchemaName, getSchemas, getServername, getSQLCurrentSequenceValue, getSQLListOfProcedures, getSQLListOfSchemas, getSQLListOfSequences, getSQLNextSequenceValue, getSqlScriptStatements, getSQLSequenceExists, getTables, getUnsupportedTableOutputMessage, getUsername, getValueFromResultSet, getXulOverlayFile, isChanged, isPartitioned, isRequiringTransactionsOnQueries, isUsingConnectionPool, needsPlaceHolder, parseStatements, putOptionalOptions, releaseSavepoint, setAccessType, setAttributes, setChanged, setConnectionPoolingProperties, setConnectSQL, setDatabaseName, setDatabasePortNumberString, setDataTablespace, setDisplayName, setHostname, setIndexTablespace, setInitialPoolSize, setInitialPoolSizeString, setMaximumPoolSize, setMaximumPoolSizeString, setName, setNamedCluster, setObjectId, setPartitioned, setPartitioningInformation, setPassword, setPluginId, setPluginName, setPreferredSchemaName, setServername, setUsername, setUsingConnectionPool, supportsAutoInc, supportsCatalogs, supportsEmptyTransactions, supportsErrorHandling, supportsErrorHandlingOnBatchUpdates, supportsIndexes, supportsRepository, supportsSchemas, supportsSequences, supportsSetCharacterStream, supportsSetLong, supportsStandardTableOutput, supportsTransactions, useSafePoints
-
-
-
-
Field Detail
-
ATRRIBUTE_CUSTOM_URL
public static final String ATRRIBUTE_CUSTOM_URL
- See Also:
- Constant Field Values
-
ATRRIBUTE_CUSTOM_DRIVER_CLASS
public static final String ATRRIBUTE_CUSTOM_DRIVER_CLASS
- See Also:
- Constant Field Values
-
DATABASE_DIALECT_ID
public static final String DATABASE_DIALECT_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
addAttribute
public void addAttribute(String attributeId, String value)
Description copied from interface:DatabaseInterface
Add extra attribute on this connection- Specified by:
addAttribute
in interfaceDatabaseInterface
- Overrides:
addAttribute
in classBaseDatabaseMeta
- Parameters:
attributeId
- the attribute identifiervalue
- the value of the attribute
-
getAccessTypeList
public int[] getAccessTypeList()
Description copied from interface:DatabaseInterface
Get the list of possible access types for a database.- Specified by:
getAccessTypeList
in interfaceDatabaseInterface
- Specified by:
getAccessTypeList
in classBaseDatabaseMeta
- Returns:
- the list of possible access types for a database.
-
getNotFoundTK
public int getNotFoundTK(boolean useAutoinc)
Description copied from interface:DatabaseInterface
Get the not found technical key.- Specified by:
getNotFoundTK
in interfaceDatabaseInterface
- Overrides:
getNotFoundTK
in classBaseDatabaseMeta
- Parameters:
useAutoinc
- Whether or not we want to use an auto increment field- Returns:
- the lowest possible technical key to be used as the NOT FOUND row in a slowly changing dimension.
- See Also:
DatabaseInterface.getNotFoundTK(boolean)
-
getDriverClass
public String getDriverClass()
Description copied from interface:DatabaseInterface
Obtain the name of the JDBC driver class that we need to use!- Specified by:
getDriverClass
in interfaceDatabaseInterface
- Returns:
- the name of the JDBC driver class for the specific database
-
getURL
public String getURL(String hostname, String port, String databaseName)
- Specified by:
getURL
in interfaceDatabaseInterface
- Parameters:
hostname
- the hostnameport
- the port as a stringdatabaseName
- the database name- Returns:
- the URL to use for connecting to the database.
-
isFetchSizeSupported
public boolean isFetchSizeSupported()
Checks whether or not the command setFetchSize() is supported by the JDBC driver...- Specified by:
isFetchSizeSupported
in interfaceDatabaseInterface
- Overrides:
isFetchSizeSupported
in classBaseDatabaseMeta
- Returns:
- true is setFetchSize() is supported!
-
supportsBitmapIndex
public boolean supportsBitmapIndex()
- Specified by:
supportsBitmapIndex
in interfaceDatabaseInterface
- Overrides:
supportsBitmapIndex
in classBaseDatabaseMeta
- Returns:
- true if the database supports bitmap indexes
-
getTruncateTableStatement
public String getTruncateTableStatement(String tableName)
- Specified by:
getTruncateTableStatement
in interfaceDatabaseInterface
- Overrides:
getTruncateTableStatement
in classBaseDatabaseMeta
- Parameters:
tableName
- The table to be truncated.- Returns:
- The SQL statement to truncate a table: remove all rows from it without a transaction
-
getAddColumnStatement
public String getAddColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean useAutoinc, String pk, boolean semicolon)
Generates the SQL statement to add a column to the specified table For this generic type, i set it to the most common possibility.- Specified by:
getAddColumnStatement
in interfaceDatabaseInterface
- Parameters:
tablename
- The table to addv
- The column defined as a valuetk
- the name of the technical key fielduseAutoinc
- whether or not this field uses auto incrementpk
- the name of the primary key fieldsemicolon
- whether or not to add a semi-colon behind the statement.- Returns:
- the SQL statement to add a column to the specified table
-
getModifyColumnStatement
public String getModifyColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean useAutoinc, String pk, boolean semicolon)
Generates the SQL statement to modify a column in the specified table- Specified by:
getModifyColumnStatement
in interfaceDatabaseInterface
- Parameters:
tablename
- The table to addv
- The column defined as a valuetk
- the name of the technical key fielduseAutoinc
- whether or not this field uses auto incrementpk
- the name of the primary key fieldsemicolon
- whether or not to add a semi-colon behind the statement.- Returns:
- the SQL statement to modify a column in the specified table
-
getFieldDefinition
public String getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean useAutoinc, boolean addFieldName, boolean addCr)
Description copied from interface:DatabaseInterface
Describe a Value as a field in the database.- Specified by:
getFieldDefinition
in interfaceDatabaseInterface
- Parameters:
v
- The value to describetk
- The field that's going to be the technical keypk
- The field that's going to be the primary keyuseAutoinc
- Use autoincrement or notaddFieldName
- Add the fieldname to the definition or notaddCr
- Add a cariage return at the end of the definition or not.- Returns:
- a value described as a field in this database.
-
getUsedLibraries
public String[] getUsedLibraries()
- Specified by:
getUsedLibraries
in interfaceDatabaseInterface
- Returns:
- the required libraries (in lib) for this database connection.
-
supportsPreparedStatementMetadataRetrieval
public boolean supportsPreparedStatementMetadataRetrieval()
Most databases allow you to retrieve result metadata by preparing a SELECT statement.- Specified by:
supportsPreparedStatementMetadataRetrieval
in interfaceDatabaseInterface
- Overrides:
supportsPreparedStatementMetadataRetrieval
in classBaseDatabaseMeta
- Returns:
- true if the database supports retrieval of query metadata from a prepared statement. False if the query needs to be executed first.
-
getSQLInsertAutoIncUnknownDimensionRow
public String getSQLInsertAutoIncUnknownDimensionRow(String schemaTable, String keyField, String versionField)
Get the SQL to insert a new empty unknown record in a dimension.- Specified by:
getSQLInsertAutoIncUnknownDimensionRow
in interfaceDatabaseInterface
- Overrides:
getSQLInsertAutoIncUnknownDimensionRow
in classBaseDatabaseMeta
- Parameters:
schemaTable
- the schema-table name to insert intokeyField
- The key fieldversionField
- the version field- Returns:
- the SQL to insert the unknown record into the SCD.
-
setDatabaseDialect
public void setDatabaseDialect(String databaseDialect)
-
getDatabaseDialect
public String getDatabaseDialect()
-
getDatabaseDialectInternal
protected DatabaseInterface getDatabaseDialectInternal()
-
resolveDialect
protected void resolveDialect(String dialectName)
-
getReservedWords
public String[] getReservedWords()
- Specified by:
getReservedWords
in interfaceDatabaseInterface
- Overrides:
getReservedWords
in classBaseDatabaseMeta
- Returns:
- an array of reserved words for the database type...
-
getEndQuote
public String getEndQuote()
- Specified by:
getEndQuote
in interfaceDatabaseInterface
- Overrides:
getEndQuote
in classBaseDatabaseMeta
- Returns:
- The end quote sequence, mostly just double quote, but sometimes ], ...
-
getFunctionSum
public String getFunctionSum()
- Specified by:
getFunctionSum
in interfaceDatabaseInterface
- Overrides:
getFunctionSum
in classBaseDatabaseMeta
- Returns:
- the function for SUM agrregate
-
getFunctionAverage
public String getFunctionAverage()
- Specified by:
getFunctionAverage
in interfaceDatabaseInterface
- Overrides:
getFunctionAverage
in classBaseDatabaseMeta
- Returns:
- the function for Average agrregate
-
getFunctionMinimum
public String getFunctionMinimum()
- Specified by:
getFunctionMinimum
in interfaceDatabaseInterface
- Overrides:
getFunctionMinimum
in classBaseDatabaseMeta
- Returns:
- the function for Minimum agrregate
-
getFunctionMaximum
public String getFunctionMaximum()
- Specified by:
getFunctionMaximum
in interfaceDatabaseInterface
- Overrides:
getFunctionMaximum
in classBaseDatabaseMeta
- Returns:
- the function for Maximum agrregate
-
getFunctionCount
public String getFunctionCount()
- Specified by:
getFunctionCount
in interfaceDatabaseInterface
- Overrides:
getFunctionCount
in classBaseDatabaseMeta
- Returns:
- the function for Count agrregate
-
getSQLQueryFields
public String getSQLQueryFields(String tableName)
Description copied from class:BaseDatabaseMeta
Returns the minimal SQL to launch in order to determine the layout of the resultset for a given database table- Specified by:
getSQLQueryFields
in interfaceDatabaseInterface
- Overrides:
getSQLQueryFields
in classBaseDatabaseMeta
- Parameters:
tableName
- The name of the table to determine the layout for- Returns:
- The SQL to launch.
-
getSQLColumnExists
public String getSQLColumnExists(String columnname, String tablename)
- Specified by:
getSQLColumnExists
in interfaceDatabaseInterface
- Overrides:
getSQLColumnExists
in classBaseDatabaseMeta
- Parameters:
columnname
- The column to verify the existance fortablename
- The table to verify the existance for- Returns:
- The SQL to execute to verify if the given table exists. If an Exception is thrown for this SQL, we don't have the column.
-
getSQLTableExists
public String getSQLTableExists(String tableName)
- Specified by:
getSQLTableExists
in interfaceDatabaseInterface
- Overrides:
getSQLTableExists
in classBaseDatabaseMeta
- Parameters:
tableName
- The table to verify the existance for- Returns:
- The SQL to execute to verify if the given table exists. If an Exception is thrown for this SQL, we don't have the table.
-
getLimitClause
public String getLimitClause(int nrRows)
- Specified by:
getLimitClause
in interfaceDatabaseInterface
- Overrides:
getLimitClause
in classBaseDatabaseMeta
- Parameters:
nrRows
- The number of rows to which we want to limit the result of the query.- Returns:
- the clause after a select statement to limit the number of rows
-
getSelectCountStatement
public String getSelectCountStatement(String tableName)
Description copied from class:BaseDatabaseMeta
Build the SQL to count the number of rows in the passed table.- Specified by:
getSelectCountStatement
in interfaceDatabaseInterface
- Overrides:
getSelectCountStatement
in classBaseDatabaseMeta
- Returns:
-
getSQLUnlockTables
public String getSQLUnlockTables(String[] tableName)
- Specified by:
getSQLUnlockTables
in interfaceDatabaseInterface
- Overrides:
getSQLUnlockTables
in classBaseDatabaseMeta
- Parameters:
tableName
- The names of the tables to unlock- Returns:
- The SQL command to unlock database tables. null is returned in case locking is not supported on the target database. null is the default value
-
getSequenceNoMaxValueOption
public String getSequenceNoMaxValueOption()
- Specified by:
getSequenceNoMaxValueOption
in interfaceDatabaseInterface
- Overrides:
getSequenceNoMaxValueOption
in classBaseDatabaseMeta
- Returns:
- string with the no max value sequence option.
-
useSchemaNameForTableList
public boolean useSchemaNameForTableList()
- Specified by:
useSchemaNameForTableList
in interfaceDatabaseInterface
- Overrides:
useSchemaNameForTableList
in classBaseDatabaseMeta
- Returns:
- true if we need to supply the schema-name to getTables in order to get a correct list of items.
-
supportsViews
public boolean supportsViews()
- Specified by:
supportsViews
in interfaceDatabaseInterface
- Overrides:
supportsViews
in classBaseDatabaseMeta
- Returns:
- true if the database supports views
-
supportsTimeStampToDateConversion
public boolean supportsTimeStampToDateConversion()
- Specified by:
supportsTimeStampToDateConversion
in interfaceDatabaseInterface
- Overrides:
supportsTimeStampToDateConversion
in classBaseDatabaseMeta
- Returns:
- true if the database supports timestamp to date conversion. For example Interbase doesn't support this!
-
getCreateTableStatement
public String getCreateTableStatement()
Description copied from class:BaseDatabaseMeta
Customizes the ValueMetaInterface defined in the base- Specified by:
getCreateTableStatement
in interfaceDatabaseInterface
- Overrides:
getCreateTableStatement
in classBaseDatabaseMeta
- Returns:
- String the create table statement
-
supportsAutoGeneratedKeys
public boolean supportsAutoGeneratedKeys()
- Specified by:
supportsAutoGeneratedKeys
in interfaceDatabaseInterface
- Overrides:
supportsAutoGeneratedKeys
in classBaseDatabaseMeta
- Returns:
- true if the database supports autoGeneratedKeys
-
getSafeFieldname
public String getSafeFieldname(String fieldName)
Description copied from class:BaseDatabaseMeta
Sanitize a string for usage as a field name- Append an underscore to any field name that matches a reserved word
- Replaces spaces with underscores
- Prefixes a string with underscore that begins with a number
- Specified by:
getSafeFieldname
in interfaceDatabaseInterface
- Overrides:
getSafeFieldname
in classBaseDatabaseMeta
- Parameters:
fieldName
- value to sanitize- Returns:
- a String safe for usage as a column name without the need for quoting
-
setSupportsTimestampDataType
public void setSupportsTimestampDataType(boolean b)
- Specified by:
setSupportsTimestampDataType
in interfaceDatabaseInterface
- Overrides:
setSupportsTimestampDataType
in classBaseDatabaseMeta
- Parameters:
b
- Set to true if the database supports the Timestamp data type (nanosecond precision and all)
-
supportsTimestampDataType
public boolean supportsTimestampDataType()
- Specified by:
supportsTimestampDataType
in interfaceDatabaseInterface
- Overrides:
supportsTimestampDataType
in classBaseDatabaseMeta
- Returns:
- true if the database supports the Timestamp data type (nanosecond precision and all)
-
supportsResultSetMetadataRetrievalOnly
public boolean supportsResultSetMetadataRetrievalOnly()
- Specified by:
supportsResultSetMetadataRetrievalOnly
in interfaceDatabaseInterface
- Overrides:
supportsResultSetMetadataRetrievalOnly
in classBaseDatabaseMeta
- Returns:
- true if this database only supports metadata retrieval on a result set, never on a statement (even if the statement has been executed)
-
getSQLValue
public String getSQLValue(ValueMetaInterface valueMeta, Object valueData, String dateFormat) throws KettleValueException
Description copied from interface:DatabaseInterface
Convert a value in the SQL equivalent. For example, convert String "Pentaho" into 'Pentaho' or into Oracle date format TO_DATE('2012/08/16 15:36:59', 'YYYY/MM/DD HH24:MI:SS')- Specified by:
getSQLValue
in interfaceDatabaseInterface
- Overrides:
getSQLValue
in classBaseDatabaseMeta
- Parameters:
valueMeta
- The description of the value. The date format used is taken from this value unless dateFormat is specified (not null or empty)valueData
- The data to convert.- Returns:
- The value SQL clause
- Throws:
KettleValueException
- in case there is a data conversion error.
-
customizeValueFromSQLType
public ValueMetaInterface customizeValueFromSQLType(ValueMetaInterface v, ResultSetMetaData rm, int index) throws SQLException
Description copied from class:BaseDatabaseMeta
Customizes the ValueMetaInterface defined in the base- Specified by:
customizeValueFromSQLType
in interfaceDatabaseInterface
- Overrides:
customizeValueFromSQLType
in classBaseDatabaseMeta
- Parameters:
v
- the determined valueMetaInterfacerm
- the sql resultindex
- the index to the column- Returns:
- ValueMetaInterface customized with the data base specific types
- Throws:
SQLException
-
isMySQLVariant
public boolean isMySQLVariant()
- Specified by:
isMySQLVariant
in interfaceDatabaseInterface
- Overrides:
isMySQLVariant
in classBaseDatabaseMeta
- Returns:
- true if the database is a MySQL variant, like MySQL 5.1, InfiniDB, InfoBright, and so on.
-
generateColumnAlias
public String generateColumnAlias(int columnIndex, String suggestedName)
Description copied from interface:DatabaseInterface
Generate a column alias given the column index and suggested name.- Specified by:
generateColumnAlias
in interfaceDatabaseInterface
- Overrides:
generateColumnAlias
in classBaseDatabaseMeta
- Parameters:
columnIndex
- Index of column in querysuggestedName
- Suggested column name- Returns:
- Column alias that is valid for this database
-
quoteSQLString
public String quoteSQLString(String string)
Description copied from interface:DatabaseInterface
Adds quotes around the string according to the database dialect and also escapes special characters like CR, LF and the quote character itself.- Specified by:
quoteSQLString
in interfaceDatabaseInterface
- Overrides:
quoteSQLString
in classBaseDatabaseMeta
- Returns:
- A string that is properly quoted for use in a SQL statement (insert, update, delete, etc)
-
isExplorable
public boolean isExplorable()
- Specified by:
isExplorable
in interfaceDatabaseInterface
- Overrides:
isExplorable
in classBaseDatabaseMeta
- Returns:
- true if this is a relational database you can explore. Return false for SAP, PALO, etc.
-
getMaxColumnsInIndex
public int getMaxColumnsInIndex()
- Specified by:
getMaxColumnsInIndex
in interfaceDatabaseInterface
- Overrides:
getMaxColumnsInIndex
in classBaseDatabaseMeta
- Returns:
- The maximum number of columns in a database, <=0 means: no known limit
-
getSQLListOfSchemas
public String getSQLListOfSchemas()
- Specified by:
getSQLListOfSchemas
in interfaceDatabaseInterface
- Overrides:
getSQLListOfSchemas
in classBaseDatabaseMeta
- Returns:
- the SQL to retrieve the list of schemas or null if the JDBC metadata needs to be used.
-
supportsNewLinesInSQL
public boolean supportsNewLinesInSQL()
- Specified by:
supportsNewLinesInSQL
in interfaceDatabaseInterface
- Overrides:
supportsNewLinesInSQL
in classBaseDatabaseMeta
- Returns:
- true if the database supports newlines in a SQL statements.
-
isSystemTable
public boolean isSystemTable(String tableName)
- Specified by:
isSystemTable
in interfaceDatabaseInterface
- Overrides:
isSystemTable
in classBaseDatabaseMeta
- Returns:
- true if the specified table is a system table
-
isDisplaySizeTwiceThePrecision
public boolean isDisplaySizeTwiceThePrecision()
- Specified by:
isDisplaySizeTwiceThePrecision
in interfaceDatabaseInterface
- Overrides:
isDisplaySizeTwiceThePrecision
in classBaseDatabaseMeta
- Returns:
- Handles the special case of DB2 where the display size returned is twice the precision. In that case, the length is the precision.
-
requiresCastToVariousForIsNull
public boolean requiresCastToVariousForIsNull()
- Specified by:
requiresCastToVariousForIsNull
in interfaceDatabaseInterface
- Overrides:
requiresCastToVariousForIsNull
in classBaseDatabaseMeta
- Returns:
- true if the database requires you to cast a parameter to varchar before comparing to null. Only required for DB2 and Vertica
-
requiresCreateTablePrimaryKeyAppend
public boolean requiresCreateTablePrimaryKeyAppend()
- Specified by:
requiresCreateTablePrimaryKeyAppend
in interfaceDatabaseInterface
- Overrides:
requiresCreateTablePrimaryKeyAppend
in classBaseDatabaseMeta
- Returns:
- true if we need to append the PRIMARY KEY block in the create table block after the fields, required for Cache.
-
supportsSequenceNoMaxValueOption
public boolean supportsSequenceNoMaxValueOption()
- Specified by:
supportsSequenceNoMaxValueOption
in interfaceDatabaseInterface
- Overrides:
supportsSequenceNoMaxValueOption
in classBaseDatabaseMeta
- Returns:
- true if the database supports the NOMAXVALUE sequence option. The default is false, AS/400 and DB2 support this.
-
setUsingDoubleDecimalAsSchemaTableSeparator
public void setUsingDoubleDecimalAsSchemaTableSeparator(boolean useDoubleDecimalSeparator)
- Specified by:
setUsingDoubleDecimalAsSchemaTableSeparator
in interfaceDatabaseInterface
- Overrides:
setUsingDoubleDecimalAsSchemaTableSeparator
in classBaseDatabaseMeta
- Parameters:
useDoubleDecimalSeparator
- true if we should use a double decimal separator to specify schema/table combinations on MS-SQL server
-
isUsingDoubleDecimalAsSchemaTableSeparator
public boolean isUsingDoubleDecimalAsSchemaTableSeparator()
- Specified by:
isUsingDoubleDecimalAsSchemaTableSeparator
in interfaceDatabaseInterface
- Overrides:
isUsingDoubleDecimalAsSchemaTableSeparator
in classBaseDatabaseMeta
- Returns:
- true if we use a double decimal separator to specify schema/table combinations on MS-SQL server
-
setForcingIdentifiersToUpperCase
public void setForcingIdentifiersToUpperCase(boolean forceUpperCase)
- Specified by:
setForcingIdentifiersToUpperCase
in interfaceDatabaseInterface
- Overrides:
setForcingIdentifiersToUpperCase
in classBaseDatabaseMeta
- Parameters:
forceUpperCase
- true if all identifiers should be forced to upper case
-
isForcingIdentifiersToUpperCase
public boolean isForcingIdentifiersToUpperCase()
- Specified by:
isForcingIdentifiersToUpperCase
in interfaceDatabaseInterface
- Overrides:
isForcingIdentifiersToUpperCase
in classBaseDatabaseMeta
- Returns:
- true if all identifiers should be forced to upper case
-
setForcingIdentifiersToLowerCase
public void setForcingIdentifiersToLowerCase(boolean forceUpperCase)
- Specified by:
setForcingIdentifiersToLowerCase
in interfaceDatabaseInterface
- Overrides:
setForcingIdentifiersToLowerCase
in classBaseDatabaseMeta
- Parameters:
forceUpperCase
- true if all identifiers should be forced to lower case
-
isForcingIdentifiersToLowerCase
public boolean isForcingIdentifiersToLowerCase()
- Specified by:
isForcingIdentifiersToLowerCase
in interfaceDatabaseInterface
- Overrides:
isForcingIdentifiersToLowerCase
in classBaseDatabaseMeta
- Returns:
- true if all identifiers should be forced to lower case
-
setQuoteAllFields
public void setQuoteAllFields(boolean quoteAllFields)
- Specified by:
setQuoteAllFields
in interfaceDatabaseInterface
- Overrides:
setQuoteAllFields
in classBaseDatabaseMeta
- Parameters:
quoteAllFields
- true if we want the database to stream results (normally this is an option just for MySQL).
-
isQuoteAllFields
public boolean isQuoteAllFields()
- Specified by:
isQuoteAllFields
in interfaceDatabaseInterface
- Overrides:
isQuoteAllFields
in classBaseDatabaseMeta
- Returns:
- true if all fields should always be quoted in db
-
setStreamingResults
public void setStreamingResults(boolean useStreaming)
- Specified by:
setStreamingResults
in interfaceDatabaseInterface
- Overrides:
setStreamingResults
in classBaseDatabaseMeta
- Parameters:
useStreaming
- true if we want the database to stream results (normally this is an option just for MySQL).
-
isStreamingResults
public boolean isStreamingResults()
- Specified by:
isStreamingResults
in interfaceDatabaseInterface
- Overrides:
isStreamingResults
in classBaseDatabaseMeta
- Returns:
- true if the database is streaming results (normally this is an option just for MySQL).
-
needsToLockAllTables
public boolean needsToLockAllTables()
- Specified by:
needsToLockAllTables
in interfaceDatabaseInterface
- Overrides:
needsToLockAllTables
in classBaseDatabaseMeta
- Returns:
- true if the database needs all repository tables to be locked, not just one ref table (R_REPOSITORY_LOG)
-
supportsSetMaxRows
public boolean supportsSetMaxRows()
- Specified by:
supportsSetMaxRows
in interfaceDatabaseInterface
- Overrides:
supportsSetMaxRows
in classBaseDatabaseMeta
- Returns:
- true if the database supports setting the maximum number of return rows in a resultset.
-
supportsGetBlob
public boolean supportsGetBlob()
- Specified by:
supportsGetBlob
in interfaceDatabaseInterface
- Overrides:
supportsGetBlob
in classBaseDatabaseMeta
- Returns:
- true if the database JDBC driver supports getBlob on the resultset. If not we must use getBytes() to get the data.
-
isDefaultingToUppercase
public boolean isDefaultingToUppercase()
- Specified by:
isDefaultingToUppercase
in interfaceDatabaseInterface
- Overrides:
isDefaultingToUppercase
in classBaseDatabaseMeta
- Returns:
- true if the database defaults to naming tables and fields in uppercase. True for most databases except for stuborn stuff like Postgres ;-)
-
setPreserveReservedCase
public void setPreserveReservedCase(boolean b)
- Specified by:
setPreserveReservedCase
in interfaceDatabaseInterface
- Overrides:
setPreserveReservedCase
in classBaseDatabaseMeta
- Parameters:
b
- Set to true if reserved words' case should be preserved
-
preserveReservedCase
public boolean preserveReservedCase()
- Specified by:
preserveReservedCase
in interfaceDatabaseInterface
- Overrides:
preserveReservedCase
in classBaseDatabaseMeta
- Returns:
- true if reserved words' case should be preserved
-
setSupportsBooleanDataType
public void setSupportsBooleanDataType(boolean b)
- Specified by:
setSupportsBooleanDataType
in interfaceDatabaseInterface
- Overrides:
setSupportsBooleanDataType
in classBaseDatabaseMeta
- Parameters:
b
- Set to true if the database supports a boolean, bit, logical, ... datatype
-
supportsBooleanDataType
public boolean supportsBooleanDataType()
- Specified by:
supportsBooleanDataType
in interfaceDatabaseInterface
- Overrides:
supportsBooleanDataType
in classBaseDatabaseMeta
- Returns:
- true if the database supports a boolean, bit, logical, ... datatype The default is false: map to a string.
-
supportsBatchUpdates
public boolean supportsBatchUpdates()
- Specified by:
supportsBatchUpdates
in interfaceDatabaseInterface
- Overrides:
supportsBatchUpdates
in classBaseDatabaseMeta
- Returns:
- true if the database JDBC driver supports batch updates For example Interbase doesn't support this!
-
getSQLLockTables
public String getSQLLockTables(String[] tableNames)
- Specified by:
getSQLLockTables
in interfaceDatabaseInterface
- Overrides:
getSQLLockTables
in classBaseDatabaseMeta
- Parameters:
tableNames
- The names of the tables to lock- Returns:
- The SQL command to lock database tables for write purposes. null is returned in case locking is not supported on the target database. null is the default value
-
supportsFloatRoundingOnUpdate
public boolean supportsFloatRoundingOnUpdate()
Description copied from class:BaseDatabaseMeta
Most databases round number(7,2) 17.29999999 to 17.30, but some don't.- Specified by:
supportsFloatRoundingOnUpdate
in interfaceDatabaseInterface
- Overrides:
supportsFloatRoundingOnUpdate
in classBaseDatabaseMeta
- Returns:
- true if the database supports roundinf of floating point data on update/insert
-
supportsSynonyms
public boolean supportsSynonyms()
- Specified by:
supportsSynonyms
in interfaceDatabaseInterface
- Overrides:
supportsSynonyms
in classBaseDatabaseMeta
- Returns:
- true if the database supports synonyms
-
getSynonymTypes
public String[] getSynonymTypes()
- Specified by:
getSynonymTypes
in interfaceDatabaseInterface
- Overrides:
getSynonymTypes
in classBaseDatabaseMeta
- Returns:
- a list of table types to retrieve synonyms for the database
-
getViewTypes
public String[] getViewTypes()
- Specified by:
getViewTypes
in interfaceDatabaseInterface
- Overrides:
getViewTypes
in classBaseDatabaseMeta
- Returns:
- a list of table types to retrieve views for the database
-
getTableTypes
public String[] getTableTypes()
- Specified by:
getTableTypes
in interfaceDatabaseInterface
- Overrides:
getTableTypes
in classBaseDatabaseMeta
- Returns:
- a list of table types to retrieve tables for the database
-
getStartQuote
public String getStartQuote()
- Specified by:
getStartQuote
in interfaceDatabaseInterface
- Overrides:
getStartQuote
in classBaseDatabaseMeta
- Returns:
- The start quote sequence, mostly just double quote, but sometimes [, ...
-
quoteReservedWords
public boolean quoteReservedWords()
- Specified by:
quoteReservedWords
in interfaceDatabaseInterface
- Overrides:
quoteReservedWords
in classBaseDatabaseMeta
- Returns:
- true if reserved words need to be double quoted ("password", "select", ...)
-
getDropColumnStatement
public String getDropColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean useAutoinc, String pk, boolean semicolon)
Description copied from class:BaseDatabaseMeta
Generates the SQL statement to drop a column from the specified table- Specified by:
getDropColumnStatement
in interfaceDatabaseInterface
- Overrides:
getDropColumnStatement
in classBaseDatabaseMeta
- Parameters:
tablename
- The table to addv
- The column defined as a valuetk
- the name of the technical key fielduseAutoinc
- whether or not this field uses auto incrementpk
- the name of the primary key fieldsemicolon
- whether or not to add a semi-colon behind the statement.- Returns:
- the SQL statement to drop a column from the specified table
-
getMaxVARCHARLength
public int getMaxVARCHARLength()
Description copied from class:BaseDatabaseMeta
Get the maximum length of a text field (VARCHAR) for this database connection. If this size is exceeded use a CLOB.- Specified by:
getMaxVARCHARLength
in interfaceDatabaseInterface
- Overrides:
getMaxVARCHARLength
in classBaseDatabaseMeta
- Returns:
- The maximum VARCHAR field length for this database type. (mostly identical to getMaxTextFieldLength() - CLOB_LENGTH)
-
getMaxTextFieldLength
public int getMaxTextFieldLength()
Description copied from class:BaseDatabaseMeta
Get the maximum length of a text field for this database connection. This includes optional CLOB, Memo and Text fields. (the maximum!)- Specified by:
getMaxTextFieldLength
in interfaceDatabaseInterface
- Overrides:
getMaxTextFieldLength
in classBaseDatabaseMeta
- Returns:
- The maximum text field length for this database type. (mostly CLOB_LENGTH)
-
getSchemaTableCombination
public String getSchemaTableCombination(String schemaName, String tablePart)
Description copied from class:BaseDatabaseMeta
Get the schema-table combination to query the right table. Usually that is SCHEMA.TABLENAME, however there are exceptions to this rule...- Specified by:
getSchemaTableCombination
in interfaceDatabaseInterface
- Overrides:
getSchemaTableCombination
in classBaseDatabaseMeta
- Parameters:
schemaName
- The schema nametablePart
- The tablename- Returns:
- the schema-table combination to query the right table.
-
getDefaultOptions
public Map<String,String> getDefaultOptions()
- Specified by:
getDefaultOptions
in interfaceDatabaseInterface
- Overrides:
getDefaultOptions
in classBaseDatabaseMeta
- Returns:
- default extra Options
-
getExtraOptions
public Map<String,String> getExtraOptions()
- Specified by:
getExtraOptions
in interfaceDatabaseInterface
- Overrides:
getExtraOptions
in classBaseDatabaseMeta
- Returns:
- all the extra options that are set to be used for the database URL
-
addExtraOption
public void addExtraOption(String databaseTypeCode, String option, String value)
Description copied from class:BaseDatabaseMeta
Add an extra option to the attributes list- Specified by:
addExtraOption
in interfaceDatabaseInterface
- Overrides:
addExtraOption
in classBaseDatabaseMeta
- Parameters:
databaseTypeCode
- The database type code for which the option appliesoption
- The option to setvalue
- The value of the option
-
getExtraOptionSeparator
public String getExtraOptionSeparator()
- Specified by:
getExtraOptionSeparator
in interfaceDatabaseInterface
- Overrides:
getExtraOptionSeparator
in classBaseDatabaseMeta
- Returns:
- The extra option separator in database URL for this platform (usually this is semicolon ; )
-
getExtraOptionValueSeparator
public String getExtraOptionValueSeparator()
- Specified by:
getExtraOptionValueSeparator
in interfaceDatabaseInterface
- Overrides:
getExtraOptionValueSeparator
in classBaseDatabaseMeta
- Returns:
- The extra option value separator in database URL for this platform (usually this is the equal sign = )
-
getExtraOptionIndicator
public String getExtraOptionIndicator()
- Specified by:
getExtraOptionIndicator
in interfaceDatabaseInterface
- Overrides:
getExtraOptionIndicator
in classBaseDatabaseMeta
- Returns:
- This indicator separates the normal URL from the options
-
supportsOptionsInURL
public boolean supportsOptionsInURL()
- Specified by:
supportsOptionsInURL
in interfaceDatabaseInterface
- Overrides:
supportsOptionsInURL
in classBaseDatabaseMeta
- Returns:
- true if the database supports connection options in the URL, false if they are put in a Properties object.
-
getExtraOptionsHelpText
public String getExtraOptionsHelpText()
- Specified by:
getExtraOptionsHelpText
in interfaceDatabaseInterface
- Overrides:
getExtraOptionsHelpText
in classBaseDatabaseMeta
- Returns:
- extra help text on the supported options on the selected database platform.
-
-