Package org.pentaho.di.core.database
Class DatabaseMeta
java.lang.Object
org.pentaho.di.shared.SharedObjectBase
org.pentaho.di.core.database.DatabaseMeta
- All Implemented Interfaces:
Cloneable
,VariableSpace
,XMLInterface
,RepositoryElementInterface
,RepositoryObjectInterface
,SharedObjectInterface
public class DatabaseMeta
extends SharedObjectBase
implements Cloneable, XMLInterface, SharedObjectInterface, VariableSpace, RepositoryElementInterface
This class defines the database specific parameters for a certain database type. It also provides static information
regarding a number of well known databases.
- Since:
- 18-05-2003
- Author:
- Matt
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Use this length in a String value to indicate that you want to use a CLOB in stead of a normal text field.static final Comparator<DatabaseMeta>
static final String[]
Short description of the access type, used in XML and the repository.static final String[]
Longer description for user interactions.static final String
The value to store in the attributes so that an empty value doesn't get lost...static final RepositoryObjectType
static final int
Connect to the database using JNDI.static final int
Connect natively through JDBC thin driver to the database.static final int
Connect to the database using OCI.static final int
Connect to the database using ODBC.static final int
Connect to the database using plugin specific method.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final int
Deprecated.static final String
-
Constructor Summary
ConstructorDescriptionCreate an empty database connectionDatabaseMeta
(String xml) Constructs a new database using an XML string snippet.DatabaseMeta
(String name, String type, String access, String host, String db, String port, String user, String pass) Construct a new database connections.DatabaseMeta
(Node con) Reads the information from an XML Node into this new database connection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtraOption
(String databaseTypeCode, String option, String value) Add an extra option to the attributes listvoid
Add a list of common options for some databases.protected String
appendExtraOptions
(String url, Map<String, String> extraOptions) void
applyDefaultOptions
(DatabaseInterface databaseInterface) String[]
Check the database connection parameters and give back an array of remarksvoid
static final void
Clear the database interfaces map.clone()
void
copyVariablesFrom
(VariableSpace space) Copy the variables from another space, without initializing with the defaults.protected boolean
databaseForBothDbInterfacesIsTheSame
(DatabaseInterface primary, DatabaseInterface secondary) This method is designed to identify whether the actual database for two database connection types is the same.deepClone
(boolean cloneUpdateFlag) environmentSubstitute
(String aString) Substitute the string using the current variable space.String[]
environmentSubstitute
(String[] aString) Replaces environment variables in an array of strings.boolean
fieldSubstitute
(String aString, RowMetaInterface rowMeta, Object[] rowData) Substitutes field values inaString
.static final DatabaseMeta
findDatabase
(List<? extends SharedObjectInterface> databases, String dbname) Find a database with a certain name in an arraylist of databases.static final DatabaseMeta
findDatabase
(List<DatabaseMeta> databases, ObjectId id) Find a database with a certain ID in an arraylist of databases.generateColumnAlias
(int columnIndex, String suggestedName) int
Return the type of database access.static final int
getAccessType
(String dbaccess) Gets you a short description of the type of database access.static final String
getAccessTypeDesc
(int dbaccess) static final String
getAccessTypeDescLong
(int dbaccess) static final int[]
getAccessTypeList
(String dbTypeDesc) getAddColumnStatement
(String tablename, ValueMetaInterface v, String tk, boolean use_autoinc, String pk, boolean semicolon) boolean
getBooleanValueOfVariable
(String variableName, boolean defaultValue) This method returns a boolean for the new variable check boxes.Customizes the ValueMetaInterface defined in the basestatic final DatabaseInterface
getDatabaseInterface
(String databaseType) Search for the right type of DatabaseInterface object and clone it.static final DatabaseInterface[]
static final Map<String,
DatabaseInterface> Return the name of the database.Return the port on which the database listens as a String.Deprecated.This is actually the plugin IDprotected DatabaseInterface
getDbInterface
(String typeCode) For testingint
Gets the description of the repository object.Returns the name of the database connectiongetDropColumnStatement
(String tablename, ValueMetaInterface v, String tk, boolean use_autoinc, String pk, boolean semicolon) getDropTableIfExistsStatement
(String tableName) Forms the drop table statement specific for a certain RDBMS.getFieldDefinition
(ValueMetaInterface v, String tk, String pk, boolean use_autoinc) getFieldDefinition
(ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr) protected LogChannelInterface
For testingReturn the hostname of the machine on which the database runs.int
getLimitClause
(int nrRows) int
int
int
Get the maximum length of a text field for this database connection.getModifyColumnStatement
(String tablename, ValueMetaInterface v, String tk, boolean use_autoinc, String pk, boolean semicolon) getName()
Returns the name of the database connectiongetNextBatchId
(Database ldb, String schemaName, String tableName, String fieldName) int
getNotFoundTK
(boolean use_autoinc) int
getNrReservedWords
(RowMetaInterface fields) Checks the fields specified for reserved wordsReturns the database ID of this database connection if a repository was used before.Gets the object revision.Get the parent of the variable space.getPartitionMeta
(String partitionId) Finds the partition metadata for the given partition iDGet the password to log into the database on this connection.The plugin ID of the database interfacestatic final int
getPortForDBType
(String strtype, String straccess) getQuotedSchemaTableCombination
(String schemaName, String tableName) Calculate the schema-table combination, usually this is the schema and table separated with a dot.Not used in this case, simply return root /Gets the repository element type for this object.String[]
getSchemas
(DatabaseMetaData databaseMetaData) getSchemaTableCombination
(String schemaName, String tableName) Deprecated.please use getQuotedSchemaTableCombination()getSeqNextvalSQL
(String sequenceName) getSQLColumnExists
(String columnname, String tablename) getSQLCurrentSequenceValue
(String sequenceName) getSQLInsertAutoIncUnknownDimensionRow
(String schemaTable, String keyField, String versionField) Get the SQL to insert a new empty unknown record in a dimension.getSQLLockTables
(String[] tableNames) getSQLQueryFields
(String tableName) getSQLSequenceExists
(String sequenceName) getSQLTableExists
(String tablename) getSQLUnlockTables
(String[] tableNames) String[]
getTables
(DatabaseMetaData databaseMetaData, String schema, String table, String[] tableTypesToGet) String[]
getTruncateTableStatement
(String schema, String tableName) getURL()
Get the username to log into the database on this connection.getValueFromResultSet
(ResultSet rs, ValueMetaInterface val, int i) getVariable
(String variableName) Get the value of a variable.getVariable
(String variableName, String defaultValue) Get the value of a variable with a default in case the variable is not found.String[]
getXML()
Describes the Object implementing this interface as XMLboolean
boolean
hasDotInField
(String fieldname) int
hashCode()
boolean
hasSpacesInField
(String fieldname) Detects if a field has spaces in the name.boolean
hasSpecialCharInField
(String fieldname) Detects if a field has spaces in the name.static int
indexOfName
(String[] databaseNames, String name) static void
init()
void
initializeVariablesFrom
(VariableSpace parent) Initialize variable space using the defaults, copy over the variables from the parent (using copyVariablesFrom()), after this the "injected" variables should be inserted (injectVariables()).void
injectVariables
(Map<String, String> prop) Inject variables.boolean
boolean
boolean
boolean
boolean
boolean
boolean
isInNeedOfQuoting
(String fieldname) Determines whether or not this field is in need of quoting:
- When the fieldname contains spaces
- When the fieldname is a reserved wordboolean
boolean
boolean
boolean
boolean
Marker used to determine if the DatabaseMeta should be allowed to be modified/saved.boolean
boolean
isReservedWord
(String word) Returns true if the string specified is a reserved word on this database type.boolean
boolean
isSystemTable
(String tableName) boolean
boolean
String[]
List the variables (not the values) that are currently in the variable space.boolean
Indicates the need to insert a placeholder (0) for auto increment fields.boolean
boolean
quoteField
(String field) Returns a quoted field if this is needed: contains spaces, is a reserved word, ...boolean
void
quoteReservedWords
(RowMetaInterface fields) Changes the names of the fields to their quoted equivalent if this is neededquoteSQLString
(String string) void
replaceMeta
(DatabaseMeta databaseMeta) void
replaceMeta
(DatabaseMeta databaseMeta, boolean cloneUpdateFlag) boolean
replaceReservedWords
(RowMetaInterface fields) Checks the fields specified for reserved words and quotes them.boolean
boolean
void
setAccessType
(int access_type) Set the type of database access.void
setAttributes
(Properties attributes) Set extra attributes on this database connectionvoid
void
setChanged
(boolean ch) void
setConnectionPoolingProperties
(Properties properties) void
setConnectSQL
(String sql) void
setDatabaseInterface
(DatabaseInterface databaseInterface) Set the system dependend database interface for this database metadata definitionvoid
setDatabaseType
(String type) void
setDataTablespace
(String data_tablespace) void
Set the name of the database.void
Sets the port on which the database listens.void
Set default values for an Oracle database.void
setDescription
(String description) Sets the description of the repository object.void
setDisplayName
(String displayName) void
setForcingIdentifiersToLowerCase
(boolean forceLowerCase) void
setForcingIdentifiersToUpperCase
(boolean forceUpperCase) void
setHostname
(String hostname) Sets the hostname of the machine on which the database runs.void
setIndexTablespace
(String index_tablespace) void
setInitialPoolSize
(int initalPoolSize) void
setInitialPoolSizeString
(String initalPoolSize) void
setMaximumPoolSize
(int maximumPoolSize) void
setMaximumPoolSizeString
(String maximumPoolSize) void
Sets the name of the database connection.void
setNamedCluster
(String namedCluster) void
setNeedUpdate
(boolean needUpdate) void
setObjectId
(ObjectId id) Sets the database ID in the repository for this object.void
setObjectRevision
(ObjectRevision objectRevision) Sets the object revision.void
setParentVariableSpace
(VariableSpace parent) Set the parent variable spacevoid
setPartitioned
(boolean partitioned) void
setPartitioningInformation
(PartitionDatabaseMeta[] partitionInfo) void
setPassword
(String password) Sets the password to log into the database on this connection.void
setPreferredSchemaName
(String preferredSchemaName) void
setPreserveReservedCase
(boolean b) void
setQuoteAllFields
(boolean quoteAllFields) void
setReadOnly
(boolean readOnly) Sets the marker used to determine if the DatabaseMeta should be allowed to be modified/saved.void
setRepositoryDirectory
(RepositoryDirectoryInterface repositoryDirectory) void
setServername
(String servername) void
setSQLServerInstance
(String instanceName) void
setStreamingResults
(boolean useStreaming) void
setSupportsBooleanDataType
(boolean b) void
setSupportsTimestampDataType
(boolean b) void
setUsername
(String username) Sets the username to log into the database on this connection.void
setUsingConnectionPool
(boolean usePool) void
setUsingDoubleDecimalAsSchemaTableSeparator
(boolean useDoubleDecimalSeparator) void
setValues
(String name, String type, String access, String host, String db, String port, String user, String pass) void
setValues
(DatabaseMeta info) void
setVariable
(String variableName, String variableValue) Sets a variable in the Kettle Variables list.void
shareVariablesWith
(VariableSpace space) Share a variable space from another variable space.stripCR
(StringBuffer sbsql) stripCR
(StringBuilder sbsql) boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
See if this database supports the setCharacterStream() method on a PreparedStatement.boolean
boolean
boolean
boolean
boolean
boolean
Deprecated.because the same database can support transactions or not.boolean
toString()
boolean
verifyAndModifyDatabaseName
(List<DatabaseMeta> databases, String oldname) Verify the name of the database and if required, change it if it already exists in the list of databases.Methods inherited from class org.pentaho.di.shared.SharedObjectBase
getChangedDate, isShared, setChangedDate, setShared
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.pentaho.di.shared.SharedObjectInterface
getChangedDate, isShared, setShared
Methods inherited from interface org.pentaho.di.core.variables.VariableSpace
environmentSubstitute
-
Field Details
-
XML_TAG
- See Also:
-
REPOSITORY_ELEMENT_TYPE
-
comparator
-
TYPE_DATABASE_NONE
Deprecated.Indicates that the connections doesn't point to a type of database yet.- See Also:
-
TYPE_DATABASE_MYSQL
Deprecated.Connection to a MySQL database- See Also:
-
TYPE_DATABASE_ORACLE
Deprecated.Connection to an Oracle database- See Also:
-
TYPE_DATABASE_AS400
Deprecated.Connection to an AS/400 (IBM iSeries) DB400 database- See Also:
-
TYPE_DATABASE_ACCESS
Deprecated.Connection to an Microsoft Access database- See Also:
-
TYPE_DATABASE_MSSQL
Deprecated.Connection to a Microsoft SQL Server database- See Also:
-
TYPE_DATABASE_DB2
Deprecated.Connection to an IBM DB2 database- See Also:
-
TYPE_DATABASE_POSTGRES
Deprecated.Connection to a PostgreSQL database- See Also:
-
TYPE_DATABASE_CACHE
Deprecated.Connection to an Intersystems Cache database- See Also:
-
TYPE_DATABASE_INFORMIX
Deprecated.Connection to an IBM Informix database- See Also:
-
TYPE_DATABASE_SYBASE
Deprecated.Connection to a Sybase ASE database- See Also:
-
TYPE_DATABASE_GUPTA
Deprecated.Connection to a Gupta SQLBase database- See Also:
-
TYPE_DATABASE_DBASE
Deprecated.Connection to a DBase III/IV/V database through JDBC- See Also:
-
TYPE_DATABASE_FIREBIRD
Deprecated.Connection to a FireBird database- See Also:
-
TYPE_DATABASE_SAPDB
Deprecated.Connection to a SAP DB database- See Also:
-
TYPE_DATABASE_HYPERSONIC
Deprecated.Connection to a Hypersonic java database- See Also:
-
TYPE_DATABASE_GENERIC
Deprecated.Connection to a generic database- See Also:
-
TYPE_DATABASE_SAPR3
Deprecated.Connection to an SAP R/3 system- See Also:
-
TYPE_DATABASE_INGRES
Deprecated.Connection to an Ingress database- See Also:
-
TYPE_DATABASE_INTERBASE
Deprecated.Connection to a Borland Interbase database- See Also:
-
TYPE_DATABASE_EXTENDB
Deprecated.Connection to an ExtenDB database- See Also:
-
TYPE_DATABASE_TERADATA
Deprecated.Connection to a Teradata database- See Also:
-
TYPE_DATABASE_ORACLE_RDB
Deprecated.Connection to an Oracle RDB database- See Also:
-
TYPE_DATABASE_H2
Deprecated.Connection to an H2 database- See Also:
-
TYPE_DATABASE_NETEZZA
Deprecated.Connection to a Netezza database- See Also:
-
TYPE_DATABASE_UNIVERSE
Deprecated.Connection to an IBM UniVerse database- See Also:
-
TYPE_DATABASE_SQLITE
Deprecated.Connection to a SQLite database- See Also:
-
TYPE_DATABASE_DERBY
Deprecated.Connection to an Apache Derby database- See Also:
-
TYPE_DATABASE_REMEDY_AR_SYSTEM
Deprecated.Connection to a BMC Remedy Action Request System- See Also:
-
TYPE_DATABASE_PALO
Deprecated.Connection to a Palo MOLAP Server- See Also:
-
TYPE_DATABASE_SYBASEIQ
Deprecated.Connection to a SybaseIQ ASE database- See Also:
-
TYPE_DATABASE_GREENPLUM
Deprecated.Connection to a Greenplum database- See Also:
-
TYPE_DATABASE_MONETDB
Deprecated.Connection to a MonetDB database- See Also:
-
TYPE_DATABASE_KINGBASEES
Deprecated.Connection to a KingbaseES database- See Also:
-
TYPE_DATABASE_VERTICA
Deprecated.Connection to a Vertica database- See Also:
-
TYPE_DATABASE_NEOVIEW
Deprecated.Connection to a Neoview database- See Also:
-
TYPE_DATABASE_LUCIDDB
Deprecated.Connection to a LucidDB database- See Also:
-
TYPE_DATABASE_INFOBRIGHT
Deprecated.Connection to an Infobright database- See Also:
-
TYPE_ACCESS_NATIVE
public static final int TYPE_ACCESS_NATIVEConnect natively through JDBC thin driver to the database.- See Also:
-
TYPE_ACCESS_ODBC
public static final int TYPE_ACCESS_ODBCConnect to the database using ODBC.- See Also:
-
TYPE_ACCESS_OCI
public static final int TYPE_ACCESS_OCIConnect to the database using OCI. (Oracle only)- See Also:
-
TYPE_ACCESS_PLUGIN
public static final int TYPE_ACCESS_PLUGINConnect to the database using plugin specific method. (SAP ERP)- See Also:
-
TYPE_ACCESS_JNDI
public static final int TYPE_ACCESS_JNDIConnect to the database using JNDI.- See Also:
-
dbAccessTypeCode
Short description of the access type, used in XML and the repository. -
dbAccessTypeDesc
Longer description for user interactions. -
CLOB_LENGTH
public static final int CLOB_LENGTHUse this length in a String value to indicate that you want to use a CLOB in stead of a normal text field.- See Also:
-
EMPTY_OPTIONS_STRING
The value to store in the attributes so that an empty value doesn't get lost...- See Also:
-
-
Constructor Details
-
DatabaseMeta
public DatabaseMeta(String name, String type, String access, String host, String db, String port, String user, String pass) Construct a new database connections. Note that not all these parameters are not always mandatory.- Parameters:
name
- The database nametype
- The type of databaseaccess
- The type of database accesshost
- The hostname or IP addressdb
- The database nameport
- The port on which the database listens.user
- The usernamepass
- The password
-
DatabaseMeta
public DatabaseMeta()Create an empty database connection -
DatabaseMeta
Constructs a new database using an XML string snippet. It expects the snippet to be enclosed inconnection
tags.- Parameters:
xml
- The XML string to parse- Throws:
KettleXMLException
- in case there is an XML parsing error
-
DatabaseMeta
Reads the information from an XML Node into this new database connection.- Parameters:
con
- The Node to read the data from- Throws:
KettleXMLException
-
-
Method Details
-
init
public static void init() -
setDefault
public void setDefault()Set default values for an Oracle database. -
addOptions
public void addOptions()Add a list of common options for some databases. -
getDatabaseInterface
- Returns:
- the system dependend database interface for this database metadata definition
-
setDatabaseInterface
Set the system dependend database interface for this database metadata definition- Parameters:
databaseInterface
- the system dependend database interface
-
getDatabaseInterface
public static final DatabaseInterface getDatabaseInterface(String databaseType) throws KettleDatabaseException Search for the right type of DatabaseInterface object and clone it.- Parameters:
databaseType
- the type of DatabaseInterface to look for (description)- Returns:
- The requested DatabaseInterface
- Throws:
KettleDatabaseException
- when the type could not be found or referenced.
-
getObjectId
Returns the database ID of this database connection if a repository was used before.- Specified by:
getObjectId
in interfaceRepositoryElementInterface
- Specified by:
getObjectId
in interfaceRepositoryObjectInterface
- Returns:
- the ID of the db connection.
-
setObjectId
Description copied from interface:RepositoryElementInterface
Sets the database ID in the repository for this object.- Specified by:
setObjectId
in interfaceRepositoryElementInterface
-
clone
-
deepClone
-
replaceMeta
-
replaceMeta
-
setValues
-
setDatabaseType
-
setValues
-
setName
Sets the name of the database connection. This name should be unique in a transformation and in general in a single repository.- Specified by:
setName
in interfaceRepositoryElementInterface
- Parameters:
name
- The name of the database connection
-
getName
Returns the name of the database connection- Specified by:
getName
in interfaceRepositoryElementInterface
- Specified by:
getName
in interfaceRepositoryObjectInterface
- Specified by:
getName
in interfaceSharedObjectInterface
- Returns:
- The name of the database connection
-
setDisplayName
-
getDisplayName
Returns the name of the database connection- Returns:
- The name of the database connection
-
getPluginId
The plugin ID of the database interface -
getAccessType
public int getAccessType()Return the type of database access. One ofTYPE_ACCESS_NATIVE
TYPE_ACCESS_ODBC
TYPE_ACCESS_OCI
- Returns:
- The type of database access.
-
setAccessType
public void setAccessType(int access_type) Set the type of database access.- Parameters:
access_type
- The access type.
-
getDatabaseTypeDesc
Deprecated.This is actually the plugin IDReturns a short description of the type of database.- Returns:
- A short description of the type of database.
-
getAccessTypeDesc
Gets you a short description of the type of database access.- Returns:
- A short description of the type of database access.
-
getHostname
Return the hostname of the machine on which the database runs.- Returns:
- The hostname of the database.
-
setHostname
Sets the hostname of the machine on which the database runs.- Parameters:
hostname
- The hostname of the machine on which the database runs.
-
getDatabasePortNumberString
Return the port on which the database listens as a String. Allows for parameterisation.- Returns:
- The database port.
-
setDBPort
Sets the port on which the database listens.- Parameters:
db_port
- The port number on which the database listens
-
getDatabaseName
Return the name of the database.- Returns:
- The database name.
-
setDBName
Set the name of the database.- Parameters:
databaseName
- The new name of the database
-
getUsername
Get the username to log into the database on this connection.- Returns:
- The username to log into the database on this connection.
-
setUsername
Sets the username to log into the database on this connection.- Parameters:
username
- The username
-
getPassword
Get the password to log into the database on this connection.- Returns:
- the password to log into the database on this connection.
-
setPassword
Sets the password to log into the database on this connection.- Parameters:
password
- the password to log into the database on this connection.
-
setServername
- Parameters:
servername
- the Informix servername
-
getServername
- Returns:
- the Informix servername
-
getDataTablespace
-
setDataTablespace
-
getIndexTablespace
-
setIndexTablespace
-
isNeedUpdate
public boolean isNeedUpdate() -
setNeedUpdate
public void setNeedUpdate(boolean needUpdate) -
setChanged
public void setChanged() -
setChanged
public void setChanged(boolean ch) -
hasChanged
public boolean hasChanged() -
clearChanged
public void clearChanged() -
toString
-
getAttributes
- Returns:
- The extra attributes for this database connection
-
setAttributes
Set extra attributes on this database connection- Parameters:
attributes
- The extra attributes to set on this database connection.
-
getXML
Description copied from interface:XMLInterface
Describes the Object implementing this interface as XML- Specified by:
getXML
in interfaceSharedObjectInterface
- Specified by:
getXML
in interfaceXMLInterface
- Returns:
- the XML string for this object
-
hashCode
public int hashCode() -
equals
-
getURL
- Throws:
KettleDatabaseException
-
getURL
- Throws:
KettleDatabaseException
-
appendExtraOptions
-
databaseForBothDbInterfacesIsTheSame
protected boolean databaseForBothDbInterfacesIsTheSame(DatabaseInterface primary, DatabaseInterface secondary) This method is designed to identify whether the actual database for two database connection types is the same. This situation can occur in two cases: 1. plugin id ofprimary
is the same as plugin id ofsecondary
2.secondary
is a descendantprimary
(with any deepness). -
getConnectionProperties
-
getExtraOptionIndicator
-
getExtraOptionSeparator
- Returns:
- The extra option separator in database URL for this platform (usually this is semicolon ; )
-
getExtraOptionValueSeparator
- Returns:
- The extra option value separator in database URL for this platform (usually this is the equal sign = )
-
addExtraOption
Add an extra option to the attributes list- Parameters:
databaseTypeCode
- The database type code for which the option appliesoption
- The option to setvalue
- The value of the option
-
applyDefaultOptions
-
supportsTransactions
Deprecated.because the same database can support transactions or not. It all depends on the database setup. Therefor, we look at the database metadata DatabaseMetaData.supportsTransactions() in stead of this.- Returns:
- true if the database supports transactions
-
supportsAutoinc
public boolean supportsAutoinc() -
supportsSequences
public boolean supportsSequences() -
getSQLSequenceExists
-
supportsBitmapIndex
public boolean supportsBitmapIndex() -
supportsSetLong
public boolean supportsSetLong() -
supportsSchemas
public boolean supportsSchemas()- Returns:
- true if the database supports schemas
-
supportsCatalogs
public boolean supportsCatalogs()- Returns:
- true if the database supports catalogs
-
supportsEmptyTransactions
public boolean supportsEmptyTransactions()- Returns:
- true when the database engine supports empty transaction. (for example Informix does not on a non-ANSI database type!)
-
supportsSetCharacterStream
public boolean supportsSetCharacterStream()See if this database supports the setCharacterStream() method on a PreparedStatement.- Returns:
- true if we can set a Stream on a field in a PreparedStatement. False if not.
-
getMaxTextFieldLength
public int getMaxTextFieldLength()Get the maximum length of a text field for this database connection. This includes optional CLOB, Memo and Text fields. (the maximum!)- Returns:
- The maximum text field length for this database type. (mostly CLOB_LENGTH)
-
getAccessType
-
getAccessTypeDesc
-
getAccessTypeDescLong
-
getDatabaseInterfaces
-
clearDatabaseInterfacesMap
public static final void clearDatabaseInterfacesMap()Clear the database interfaces map. The map is cached by getDatabaseInterfacesMap(), but in some instances it may need to be reloaded (such as adding/updating Database plugins). After calling clearDatabaseInterfacesMap(), the next call to getDatabaseInterfacesMap() will reload the map. -
getDatabaseInterfacesMap
-
getAccessTypeList
-
getPortForDBType
-
getDefaultDatabasePort
public int getDefaultDatabasePort() -
getNotFoundTK
public int getNotFoundTK(boolean use_autoinc) -
getDriverClass
-
stripCR
-
stripCR
-
stripCR
-
getSeqNextvalSQL
-
getSQLCurrentSequenceValue
-
isFetchSizeSupported
public boolean isFetchSizeSupported() -
needsPlaceHolder
public boolean needsPlaceHolder()Indicates the need to insert a placeholder (0) for auto increment fields.- Returns:
- true if we need a placeholder for auto increment fields in insert statements.
-
getFunctionSum
-
getFunctionAverage
-
getFunctionMaximum
-
getFunctionMinimum
-
getFunctionCount
-
checkParameters
Check the database connection parameters and give back an array of remarks- Returns:
- an array of remarks Strings
-
getSchemaTableCombination
Deprecated.please use getQuotedSchemaTableCombination()This is now replaced with getQuotedSchemaTableCombination(), enforcing the use of the quoteFields call- Parameters:
schemaName
-tableName
-- Returns:
-
getQuotedSchemaTableCombination
Calculate the schema-table combination, usually this is the schema and table separated with a dot. (schema.table)- Parameters:
schemaName
- the schema-name or null if no schema is used.tableName
- the table name- Returns:
- the schemaname-tablename combination
-
isClob
-
getFieldDefinition
-
getFieldDefinition
public String getFieldDefinition(ValueMetaInterface v, String tk, String pk, boolean use_autoinc, boolean add_fieldname, boolean add_cr) -
getLimitClause
-
getSQLQueryFields
- Parameters:
tableName
- The table or schema-table combination. We expect this to be quoted properly already!- Returns:
- the SQL for to get the fields of this table.
-
getAddColumnStatement
public String getAddColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean use_autoinc, String pk, boolean semicolon) -
getDropColumnStatement
public String getDropColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean use_autoinc, String pk, boolean semicolon) -
getModifyColumnStatement
public String getModifyColumnStatement(String tablename, ValueMetaInterface v, String tk, boolean use_autoinc, String pk, boolean semicolon) -
getReservedWords
- Returns:
- an array of reserved words for the database type...
-
quoteReservedWords
public boolean quoteReservedWords()- Returns:
- true if reserved words need to be double quoted ("password", "select", ...)
-
getStartQuote
- Returns:
- The start quote sequence, mostly just double quote, but sometimes [, ...
-
getEndQuote
- Returns:
- The end quote sequence, mostly just double quote, but sometimes ], ...
-
quoteField
Returns a quoted field if this is needed: contains spaces, is a reserved word, ...- Parameters:
field
- The fieldname to check for quoting- Returns:
- The quoted field (if this is needed.
-
isInNeedOfQuoting
Determines whether or not this field is in need of quoting:
- When the fieldname contains spaces
- When the fieldname is a reserved word- Parameters:
fieldname
- the fieldname to check if there is a need for quoting- Returns:
- true if the fieldname needs to be quoted.
-
isReservedWord
Returns true if the string specified is a reserved word on this database type.- Parameters:
word
- The word to check- Returns:
- true if word is a reserved word on this database.
-
hasSpacesInField
Detects if a field has spaces in the name. We need to quote the field in that case.- Parameters:
fieldname
- The fieldname to check for spaces- Returns:
- true if the fieldname contains spaces
-
hasSpecialCharInField
Detects if a field has spaces in the name. We need to quote the field in that case.- Parameters:
fieldname
- The fieldname to check for spaces- Returns:
- true if the fieldname contains spaces
-
hasDotInField
-
replaceReservedWords
Checks the fields specified for reserved words and quotes them.- Parameters:
fields
- the list of fields to check- Returns:
- true if one or more values have a name that is a reserved word on this database type.
-
getNrReservedWords
Checks the fields specified for reserved words- Parameters:
fields
- the list of fields to check- Returns:
- The nr of reserved words for this database.
-
getTableTypes
- Returns:
- a list of types to get the available tables
-
getViewTypes
- Returns:
- a list of types to get the available views
-
getSynonymTypes
- Returns:
- a list of types to get the available synonyms
-
useSchemaNameForTableList
public boolean useSchemaNameForTableList()- 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()- Returns:
- true if the database supports views
-
supportsSynonyms
public boolean supportsSynonyms()- Returns:
- true if the database supports synonyms
-
getSQLListOfProcedures
- Returns:
- The SQL on this database to get a list of stored procedures.
-
getTruncateTableStatement
- Parameters:
tableName
- The tablename to be truncated- Returns:
- The SQL statement to remove all rows from the specified statement, if possible without using transactions
-
supportsFloatRoundingOnUpdate
public boolean supportsFloatRoundingOnUpdate()- Returns:
- true if the database rounds floating point numbers to the right precision. For example if the target field is number(7,2) the value 12.399999999 is converted into 12.40
-
getSQLLockTables
- Parameters:
tableNames
- The names of the tables to lock- Returns:
- The SQL commands to lock database tables for write purposes. null is returned in case locking is not supported on the target database.
-
getSQLUnlockTables
- Parameters:
tableNames
- The names of the tables to unlock- Returns:
- The SQL commands to unlock databases tables. null is returned in case locking is not supported on the target database.
-
getFeatureSummary
- Returns:
- a feature list for the chosen database type.
-
supportsTimeStampToDateConversion
public boolean supportsTimeStampToDateConversion()- Returns:
- true if the database result sets support getTimeStamp() to retrieve date-time. (Date)
-
supportsBatchUpdates
public boolean supportsBatchUpdates()- Returns:
- true if the database JDBC driver supports batch updates For example Interbase doesn't support this!
-
supportsBooleanDataType
public boolean supportsBooleanDataType()- Returns:
- true if the database supports a boolean, bit, logical, ... datatype
-
setSupportsBooleanDataType
public void setSupportsBooleanDataType(boolean b) - Parameters:
b
- Set to true if the database supports a boolean, bit, logical, ... datatype
-
supportsTimestampDataType
public boolean supportsTimestampDataType()- Returns:
- true if the database supports the Timestamp data type (nanosecond precision and all)
-
setSupportsTimestampDataType
public void setSupportsTimestampDataType(boolean b) - Parameters:
b
- Set to true if the database supports the Timestamp data type (nanosecond precision and all)
-
preserveReservedCase
public boolean preserveReservedCase()- Returns:
- true if reserved words' case should be preserved
-
setPreserveReservedCase
public void setPreserveReservedCase(boolean b) -
quoteReservedWords
Changes the names of the fields to their quoted equivalent if this is needed- Parameters:
fields
- The row of fields to change
-
getExtraOptions
- Returns:
- a map of all the extra URL options you want to set.
-
supportsOptionsInURL
public boolean supportsOptionsInURL()- Returns:
- true if the database supports connection options in the URL, false if they are put in a Properties object.
-
getExtraOptionsHelpText
- Returns:
- extra help text on the supported options on the selected database platform.
-
supportsGetBlob
public boolean supportsGetBlob()- Returns:
- true if the database JDBC driver supports getBlob on the resultset. If not we must use getBytes() to get the data.
-
getConnectSQL
- Returns:
- The SQL to execute right after connecting
-
setConnectSQL
- Parameters:
sql
- The SQL to execute right after connecting
-
supportsSetMaxRows
public boolean supportsSetMaxRows()- Returns:
- true if the database supports setting the maximum number of return rows in a resultset.
-
verifyAndModifyDatabaseName
Verify the name of the database and if required, change it if it already exists in the list of databases.- Parameters:
databases
- the databases to check against.oldname
- the old name of the database- Returns:
- the new name of the database connection
-
isUsingConnectionPool
public boolean isUsingConnectionPool()- Returns:
- true if we want to use a database connection pool
-
setUsingConnectionPool
public void setUsingConnectionPool(boolean usePool) - Parameters:
usePool
- true if we want to use a database connection pool
-
getMaximumPoolSize
public int getMaximumPoolSize()- Returns:
- the maximum pool size
-
getMaximumPoolSizeString
- Returns:
- the maximum pool size variable name
-
setMaximumPoolSize
public void setMaximumPoolSize(int maximumPoolSize) - Parameters:
maximumPoolSize
- the maximum pool size
-
setMaximumPoolSizeString
- Parameters:
maximumPoolSize
- the maximum pool size variable name
-
getInitialPoolSize
public int getInitialPoolSize()- Returns:
- the initial pool size
-
getInitialPoolSizeString
- Returns:
- the initial pool size variable name
-
setInitialPoolSize
public void setInitialPoolSize(int initalPoolSize) - Parameters:
initalPoolSize
- the initial pool size
-
setInitialPoolSizeString
- Parameters:
initalPoolSize
- the initial pool size variable name
-
isPartitioned
public boolean isPartitioned()- Returns:
- true if the connection contains partitioning information
-
setPartitioned
public void setPartitioned(boolean partitioned) - Parameters:
partitioned
- true if the connection is set to contain partitioning information
-
getPartitioningInformation
- Returns:
- the available partition/host/databases/port combinations in the cluster
-
setPartitioningInformation
- Parameters:
partitionInfo
- the available partition/host/databases/port combinations in the cluster
-
getPartitionMeta
Finds the partition metadata for the given partition iD- Parameters:
partitionId
- The partition ID to look for- Returns:
- the partition database metadata or null if nothing was found.
-
getConnectionPoolingProperties
-
setConnectionPoolingProperties
-
getSQLTableExists
-
getSQLColumnExists
-
needsToLockAllTables
public boolean needsToLockAllTables() -
isStreamingResults
public boolean isStreamingResults()- Returns:
- true if the database is streaming results (normally this is an option just for MySQL).
-
setStreamingResults
public void setStreamingResults(boolean useStreaming) - Parameters:
useStreaming
- true if we want the database to stream results (normally this is an option just for MySQL).
-
isQuoteAllFields
public boolean isQuoteAllFields()- Returns:
- true if all fields should always be quoted in db
-
setQuoteAllFields
public void setQuoteAllFields(boolean quoteAllFields) - Parameters:
quoteAllFields
- true if all fields in DB should be quoted.
-
isForcingIdentifiersToLowerCase
public boolean isForcingIdentifiersToLowerCase()- Returns:
- true if all identifiers should be forced to lower case
-
setForcingIdentifiersToLowerCase
public void setForcingIdentifiersToLowerCase(boolean forceLowerCase) - Parameters:
forceLowerCase
- true if all identifiers should be forced to lower case
-
isForcingIdentifiersToUpperCase
public boolean isForcingIdentifiersToUpperCase()- Returns:
- true if all identifiers should be forced to upper case
-
setForcingIdentifiersToUpperCase
public void setForcingIdentifiersToUpperCase(boolean forceUpperCase) - Parameters:
forceUpperCase
- true if all identifiers should be forced to upper case
-
findDatabase
public static final DatabaseMeta findDatabase(List<? extends SharedObjectInterface> databases, String dbname) Find a database with a certain name in an arraylist of databases.- Parameters:
databases
- The ArrayList of databasesdbname
- The name of the database connection- Returns:
- The database object if one was found, null otherwise.
-
indexOfName
-
findDatabase
Find a database with a certain ID in an arraylist of databases.- Parameters:
databases
- The ArrayList of databasesid
- The id of the database connection- Returns:
- The database object if one was found, null otherwise.
-
copyVariablesFrom
Description copied from interface:VariableSpace
Copy the variables from another space, without initializing with the defaults. This does not affect any parent relationship.- Specified by:
copyVariablesFrom
in interfaceVariableSpace
- Parameters:
space
- the space to copy the variables from.
-
environmentSubstitute
Description copied from interface:VariableSpace
Substitute the string using the current variable space.- Specified by:
environmentSubstitute
in interfaceVariableSpace
- Parameters:
aString
- The string to substitute.- Returns:
- The substituted string.
-
environmentSubstitute
Description copied from interface:VariableSpace
Replaces environment variables in an array of strings. See also: environmentSubstitute(String string)- Specified by:
environmentSubstitute
in interfaceVariableSpace
- Parameters:
aString
- The array of strings that wants its variables to be replaced.- Returns:
- the array with the environment variables replaced.
-
fieldSubstitute
public String fieldSubstitute(String aString, RowMetaInterface rowMeta, Object[] rowData) throws KettleValueException Description copied from interface:VariableSpace
Substitutes field values inaString
. Field values are of the form "?{}". The values are retrieved from the specified row. Please note that the getString() method is used to convert to a String, for all values in the row. - Specified by:
fieldSubstitute
in interfaceVariableSpace
- Parameters:
aString
- the string on which to apply the substitution.rowMeta
- The row metadata to use.rowData
- The row data to use- Returns:
- the string with the substitution applied.
- Throws:
KettleValueException
- In case there is a String conversion error
-
getParentVariableSpace
Description copied from interface:VariableSpace
Get the parent of the variable space.- Specified by:
getParentVariableSpace
in interfaceVariableSpace
- Returns:
- the parent.
-
setParentVariableSpace
Description copied from interface:VariableSpace
Set the parent variable space- Specified by:
setParentVariableSpace
in interfaceVariableSpace
- Parameters:
parent
- The parent variable space to set
-
getVariable
Description copied from interface:VariableSpace
Get the value of a variable with a default in case the variable is not found.- Specified by:
getVariable
in interfaceVariableSpace
- Parameters:
variableName
- The name of the variabledefaultValue
- The default value in case the variable could not be found- Returns:
- the String value of a variable
-
getVariable
Description copied from interface:VariableSpace
Get the value of a variable.- Specified by:
getVariable
in interfaceVariableSpace
- Parameters:
variableName
- The name of the variable- Returns:
- the String value of a variable or null in case the variable could not be found.
-
getBooleanValueOfVariable
Description copied from interface:VariableSpace
This method returns a boolean for the new variable check boxes. If the variable name is not set or the variable name is not specified, this method simply returns the default value. If not, it convert the variable value to a boolean. "Y", "YES" and "TRUE" all convert to true. (case insensitive)- Specified by:
getBooleanValueOfVariable
in interfaceVariableSpace
- Parameters:
variableName
- The variable to look up.defaultValue
- The default value to return.- Returns:
- See Also:
-
static method ValueMeta.convertStringToBoolean()
-
initializeVariablesFrom
Description copied from interface:VariableSpace
Initialize variable space using the defaults, copy over the variables from the parent (using copyVariablesFrom()), after this the "injected" variables should be inserted (injectVariables()). The parent is set as parent variable space.- Specified by:
initializeVariablesFrom
in interfaceVariableSpace
- Parameters:
parent
- the parent to start from, or null if root.
-
listVariables
Description copied from interface:VariableSpace
List the variables (not the values) that are currently in the variable space.- Specified by:
listVariables
in interfaceVariableSpace
- Returns:
- Array of String variable names.
-
setVariable
Description copied from interface:VariableSpace
Sets a variable in the Kettle Variables list.- Specified by:
setVariable
in interfaceVariableSpace
- Parameters:
variableName
- The name of the variable to setvariableValue
- The value of the variable to set. If the variableValue is null, the variable is cleared from the list.
-
injectVariables
Description copied from interface:VariableSpace
Inject variables. The behaviour should be that the properties object will be stored and at the time the VariableSpace is initialized (or upon calling this method if the space is already initialized). After injecting the link of the properties object should be removed.- Specified by:
injectVariables
in interfaceVariableSpace
- Parameters:
prop
- Properties object containing key-value pairs.
-
getSQLServerInstance
- Returns:
- the SQL Server instance
-
setSQLServerInstance
- Parameters:
instanceName
- the SQL Server instance
-
isUsingDoubleDecimalAsSchemaTableSeparator
public boolean isUsingDoubleDecimalAsSchemaTableSeparator()- Returns:
- true if the Microsoft SQL server uses two decimals (..) to separate schema and table (default==false).
-
setUsingDoubleDecimalAsSchemaTableSeparator
public void setUsingDoubleDecimalAsSchemaTableSeparator(boolean useDoubleDecimalSeparator) - Parameters:
useDoubleDecimalSeparator
- true if we want the database to stream results (normally this is an option just for MySQL).
-
isRequiringTransactionsOnQueries
public boolean isRequiringTransactionsOnQueries()- Returns:
- true if this database needs a transaction to perform a query (auto-commit turned off).
-
testConnection
-
testConnectionSuccess
-
getDatabaseFactory
- Throws:
Exception
-
getPreferredSchemaName
-
setPreferredSchemaName
-
getRepositoryDirectory
Not used in this case, simply return root /- Specified by:
getRepositoryDirectory
in interfaceRepositoryElementInterface
-
setRepositoryDirectory
- Specified by:
setRepositoryDirectory
in interfaceRepositoryElementInterface
-
getRepositoryElementType
Description copied from interface:RepositoryElementInterface
Gets the repository element type for this object.- Specified by:
getRepositoryElementType
in interfaceRepositoryElementInterface
- Returns:
- the repository element type for this object
-
getObjectRevision
Description copied from interface:RepositoryElementInterface
Gets the object revision.- Specified by:
getObjectRevision
in interfaceRepositoryElementInterface
- Returns:
- the object revision
-
setObjectRevision
Description copied from interface:RepositoryElementInterface
Sets the object revision.- Specified by:
setObjectRevision
in interfaceRepositoryElementInterface
-
getDescription
Description copied from interface:RepositoryElementInterface
Gets the description of the repository object.- Specified by:
getDescription
in interfaceRepositoryElementInterface
- Returns:
-
setDescription
Description copied from interface:RepositoryElementInterface
Sets the description of the repository object.- Specified by:
setDescription
in interfaceRepositoryElementInterface
-
supportsSequenceNoMaxValueOption
public boolean supportsSequenceNoMaxValueOption() -
requiresCreateTablePrimaryKeyAppend
public boolean requiresCreateTablePrimaryKeyAppend() -
requiresCastToVariousForIsNull
public boolean requiresCastToVariousForIsNull() -
isDisplaySizeTwiceThePrecision
public boolean isDisplaySizeTwiceThePrecision() -
supportsPreparedStatementMetadataRetrieval
public boolean supportsPreparedStatementMetadataRetrieval() -
isSystemTable
-
getSQLListOfSchemas
-
getMaxColumnsInIndex
public int getMaxColumnsInIndex() -
supportsErrorHandlingOnBatchUpdates
public boolean supportsErrorHandlingOnBatchUpdates() -
getSQLInsertAutoIncUnknownDimensionRow
public String getSQLInsertAutoIncUnknownDimensionRow(String schemaTable, String keyField, String versionField) Get the SQL to insert a new empty unknown record in a dimension.- 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.
-
isExplorable
public boolean isExplorable()- Returns:
- true if this is a relational database you can explore. Return false for SAP, PALO, etc.
-
getSQLListOfSequences
- Returns:
- The SQL on this database to get a list of sequences.
-
quoteSQLString
-
generateColumnAlias
-
isMySQLVariant
public boolean isMySQLVariant() -
getNextBatchId
public Long getNextBatchId(Database ldb, String schemaName, String tableName, String fieldName) throws KettleDatabaseException - Throws:
KettleDatabaseException
-
getValueFromResultSet
public Object getValueFromResultSet(ResultSet rs, ValueMetaInterface val, int i) throws KettleDatabaseException - Throws:
KettleDatabaseException
-
isReadOnly
public boolean isReadOnly()Marker used to determine if the DatabaseMeta should be allowed to be modified/saved. It does NOT prevent object modification.- Returns:
-
setReadOnly
public void setReadOnly(boolean readOnly) Sets the marker used to determine if the DatabaseMeta should be allowed to be modified/saved. Setting to true does NOT prevent object modification. -
getSequenceNoMaxValueOption
-
supportsAutoGeneratedKeys
public boolean supportsAutoGeneratedKeys()- Returns:
- true if the database supports autoGeneratedKeys
-
getCreateTableStatement
Customizes the ValueMetaInterface defined in the base- Returns:
- String the create table statement
-
getDropTableIfExistsStatement
Forms the drop table statement specific for a certain RDBMS.- Parameters:
tableName
- Name of the table to drop- Returns:
- Drop table statement specific for the current database
- See Also:
-
getGeneralLogger
For testing -
getDbInterface
For testing- Throws:
KettleDatabaseException
-
getTables
public ResultSet getTables(DatabaseMetaData databaseMetaData, String schema, String table, String[] tableTypesToGet) throws SQLException - Throws:
SQLException
-
getSchemas
- Throws:
SQLException
-
getNamedCluster
-
setNamedCluster
-