public class JDBCMetadataProcessor extends Object implements MetadataProcessor<Connection>
DatabaseMetaData
and creates metadata through the MetadataFactory
.Modifier and Type | Field and Description |
---|---|
protected boolean |
useFullSchemaName |
FQN, SOURCE_PREFIX
Constructor and Description |
---|
JDBCMetadataProcessor() |
Modifier and Type | Method and Description |
---|---|
protected Column |
addColumn(ResultSet columns,
Table table,
MetadataFactory metadataFactory,
int rsColumns)
Add a column to the given table based upon the current row of the columns resultset
|
protected Table |
addTable(MetadataFactory metadataFactory,
String tableCatalog,
String tableSchema,
String tableName,
String remarks,
String fullName) |
protected Table |
addTable(MetadataFactory metadataFactory,
String tableCatalog,
String tableSchema,
String tableName,
String remarks,
String fullName,
ResultSet tables) |
protected ResultSet |
executeSequenceQuery(Connection conn)
Return a result set with three columns - sequence_catalog, sequence_schema, and sequence_name
or null if sequences are not supported
|
String |
getCatalog() |
protected String |
getCatalogTerm() |
String |
getColumnNamePattern() |
void |
getConnectorMetadata(Connection conn,
MetadataFactory metadataFactory) |
String |
getExcludeProcedures() |
String |
getExcludeSequences() |
String |
getExcludeTables() |
protected String |
getFullyQualifiedName(String catalogName,
String schemaName,
String objectName,
boolean quoted) |
protected void |
getGeographyMetadata(Column c,
Connection conn,
String tableCatalog,
String tableSchema,
String tableName,
String columnName)
Get the geospatial metadata for the column, including srid, type, and dimensionality
|
protected String |
getGeographyMetadataTableName()
Return the name of the metadata table or view for geography metadata
that conforms to the simple features specification or null if none exists
|
protected void |
getGeometryMetadata(Column c,
Connection conn,
String tableCatalog,
String tableSchema,
String tableName,
String columnName)
Get the geospatial metadata for the column, including srid, type, and dimensionality
|
protected String |
getGeometryMetadataTableName()
Return the name of the metadata table or view for geometry metadata
that conforms to the simple features specification or null if none exists
|
protected void |
getGeospatialMetadata(Column c,
Connection conn,
String tableCatalog,
String tableSchema,
String tableName,
String columnName,
Class<? extends AbstractGeospatialType> clazz) |
protected boolean |
getIndexInfoForTable(String catalogName,
String schemaName,
String tableName,
boolean uniqueOnly,
boolean approximateIndexes,
String tableType)
Override to control or disable the default index logic
|
protected String |
getNativeComponentType(String typeName)
Extract the native component type from the typeName,
or return null if that is not possible.
|
String |
getProcedureNamePattern() |
protected String |
getRuntimeType(int type,
String typeName,
int precision) |
protected String |
getRuntimeType(int type,
String typeName,
int precision,
int scale) |
String |
getSchemaName() |
String |
getSchemaPattern() |
protected String |
getSchemaTerm() |
String |
getSequenceNamePattern() |
protected String |
getSequenceNextSQL(String fullyQualifiedName)
Return the native sql for getting the next value or null if not supported
|
void |
getSequences(MetadataFactory metadataFactory,
Connection conn) |
String |
getTableNamePattern() |
protected void |
getTableStatistics(Connection conn,
String catalog,
String schema,
String name,
Table table) |
protected String |
getTableTerm() |
String[] |
getTableTypes() |
boolean |
isAutoCreateUniqueConstraints() |
protected boolean |
isHiddenSchema(String catalog,
String schema)
If the schema is hidden regardless of the specified schema pattern
|
boolean |
isImportApproximateIndexes() |
boolean |
isImportForeignKeys() |
boolean |
isImportIndexes() |
boolean |
isImportKeys() |
boolean |
isImportLargeAsLob() |
boolean |
isImportProcedures() |
boolean |
isImportRowIdAsBinary() |
boolean |
isImportSequences() |
boolean |
isImportStatistics() |
boolean |
isQuoteNameInSource() |
protected boolean |
isUnsignedTypeName(String name)
Determine if the type name represents an unsigned type
|
boolean |
isUseAnyIndexCardinality() |
boolean |
isUseCatalogName() |
boolean |
isUseFullSchemaName() |
boolean |
isUseIntegralTypes() |
boolean |
isUseProcedureSpecificName() |
boolean |
isUseQualifiedName() |
boolean |
isWidenUnsingedTypes() |
protected String |
modifyProcedureNameInSource(String nameInSource)
Override to modify the nameInSource for a procedure
|
void |
process(MetadataFactory metadataFactory,
Connection conn) |
protected String |
quoteName(String name) |
void |
setAutoCreateUniqueConstraints(boolean autoCreateUniqueConstraints) |
void |
setCatalog(String catalog) |
void |
setColumnNamePattern(String columnNamePattern) |
void |
setEndQuoteString(String quoteString) |
void |
setExcludeProcedures(String excludeProcedures) |
void |
setExcludeSequences(String excludeSequences) |
void |
setExcludeTables(String excludeTables) |
void |
setImportApproximateIndexes(boolean importApproximateIndexes) |
void |
setImportForeignKeys(boolean importForeignKeys) |
void |
setImportIndexes(boolean importIndexes) |
void |
setImportKeys(boolean importKeys) |
void |
setImportLargeAsLob(boolean importLargeAsLob) |
void |
setImportProcedures(boolean importProcedures) |
void |
setImportRowIdAsBinary(boolean importRowIdAsBinary) |
void |
setImportSequences(boolean importSequences) |
void |
setImportStatistics(boolean importStatistics) |
void |
setProcedureNamePattern(String procedureNamePattern) |
void |
setQuoteNameInSource(boolean quoteIdentifiers) |
void |
setQuoteString(String quoteString) |
void |
setSchemaName(String schema) |
void |
setSchemaPattern(String schema) |
void |
setSequenceNamePattern(String sequenceNamePattern) |
void |
setStartQuoteString(String quoteString) |
void |
setTableNamePattern(String tableNamePattern) |
void |
setTableTypes(String[] tableTypes) |
void |
setUseAnyIndexCardinality(boolean useAnyIndexCardinality) |
void |
setUseCatalogName(boolean useCatalog) |
void |
setUseFullSchemaName(boolean useFullSchemaName) |
void |
setUseIntegralTypes(boolean useIntegralTypes) |
void |
setUseProcedureSpecificName(boolean useProcedureSpecificName) |
void |
setUseQualifiedName(boolean useQualifiedName) |
void |
setWidenUnsignedTypes(boolean widenUnsignedTypes) |
void |
setWidenUnsingedTypes(boolean widenUnsingedTypes)
Deprecated.
|
protected boolean |
shouldExclude(String fullName) |
public void process(MetadataFactory metadataFactory, Connection conn) throws TranslatorException
process
in interface MetadataProcessor<Connection>
TranslatorException
public void getConnectorMetadata(Connection conn, MetadataFactory metadataFactory) throws SQLException
SQLException
protected boolean isUnsignedTypeName(String name)
name
- protected void getTableStatistics(Connection conn, String catalog, String schema, String name, Table table) throws SQLException
conn
- catalog
- schema
- name
- table
- SQLException
protected String modifyProcedureNameInSource(String nameInSource)
nameInSource
- protected boolean shouldExclude(String fullName)
protected Table addTable(MetadataFactory metadataFactory, String tableCatalog, String tableSchema, String tableName, String remarks, String fullName, ResultSet tables) throws SQLException
SQLException
protected String getCatalogTerm()
protected String getSchemaTerm()
protected String getTableTerm()
protected Table addTable(MetadataFactory metadataFactory, String tableCatalog, String tableSchema, String tableName, String remarks, String fullName)
metadataFactory
- tableCatalog
- tableSchema
- tableName
- remarks
- fullName
- protected Column addColumn(ResultSet columns, Table table, MetadataFactory metadataFactory, int rsColumns) throws SQLException
columns
- table
- metadataFactory
- rsColumns
- SQLException
protected String getNativeComponentType(String typeName)
typeName
- public void getSequences(MetadataFactory metadataFactory, Connection conn) throws SQLException
SQLException
protected ResultSet executeSequenceQuery(Connection conn) throws SQLException
conn
- SQLException
protected String getSequenceNextSQL(String fullyQualifiedName)
fullyQualifiedName
- protected boolean getIndexInfoForTable(String catalogName, String schemaName, String tableName, boolean uniqueOnly, boolean approximateIndexes, String tableType)
catalogName
- schemaName
- tableName
- uniqueOnly
- approximateIndexes
- tableType
- protected String getFullyQualifiedName(String catalogName, String schemaName, String objectName, boolean quoted)
public void setTableNamePattern(String tableNamePattern)
public void setTableTypes(String[] tableTypes)
@TranslatorProperty(display="Table Types", category=IMPORT, description="Comma separated list - without spaces - of imported table types. null returns all types") public String[] getTableTypes()
public void setUseFullSchemaName(boolean useFullSchemaName)
public void setProcedureNamePattern(String procedureNamePattern)
public void setImportIndexes(boolean importIndexes)
public void setImportKeys(boolean importKeys)
public void setImportProcedures(boolean importProcedures)
public void setImportApproximateIndexes(boolean importApproximateIndexes)
@Deprecated public void setWidenUnsingedTypes(boolean widenUnsingedTypes)
setWidenUnsignedTypes(boolean)
public void setWidenUnsignedTypes(boolean widenUnsignedTypes)
public void setQuoteNameInSource(boolean quoteIdentifiers)
public void setCatalog(String catalog)
public void setSchemaPattern(String schema)
public void setSchemaName(String schema)
public void setUseProcedureSpecificName(boolean useProcedureSpecificName)
public void setUseCatalogName(boolean useCatalog)
public void setAutoCreateUniqueConstraints(boolean autoCreateUniqueConstraints)
public void setExcludeProcedures(String excludeProcedures)
public void setExcludeTables(String excludeTables)
public void setUseQualifiedName(boolean useQualifiedName)
public void setUseAnyIndexCardinality(boolean useAnyIndexCardinality)
public void setImportStatistics(boolean importStatistics)
public void setImportForeignKeys(boolean importForeignKeys)
public void setColumnNamePattern(String columnNamePattern)
@TranslatorProperty(display="Import Procedures", category=IMPORT, description="true to import procedures and procedure columns - Note that it is not always possible to import procedure result set columns due to database limitations. It is also not currently possible to import overloaded procedures.") public boolean isImportProcedures()
@TranslatorProperty(display="Import Keys", category=IMPORT, description="true to import primary and foreign keys - NOTE foreign keys to tables that are not imported will be ignored") public boolean isImportKeys()
@TranslatorProperty(display="Import Foreign Key", category=IMPORT, description="true to import foreign keys") public boolean isImportForeignKeys()
@TranslatorProperty(display="Import Indexes", category=IMPORT, description="true to import index/unique key/cardinality information") public boolean isImportIndexes()
@TranslatorProperty(display="Procedure Name Pattern", category=IMPORT, description=" a procedure name pattern; must match the procedure name as it is stored in the database") public String getProcedureNamePattern()
@TranslatorProperty(display="Use Full Schema Name", category=IMPORT, description="When false, directs the importer to drop the source catalog/schema from the Teiid object name, so that the Teiid fully qualified name will be in the form of <model name>.<table name> - Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception. This option does not affect the name in source property.") public boolean isUseFullSchemaName()
@TranslatorProperty(display="Table Name Pattern", category=IMPORT, description=" a table name pattern; must match the table name as it is stored in the database") public String getTableNamePattern()
@TranslatorProperty(display="catalog", category=IMPORT, description="a catalog name; must match the catalog name as it is stored in the database; \"\" retrieves those without a catalog; null means that the catalog name should not be used to narrow the search") public String getCatalog()
@TranslatorProperty(display="Schema Pattern", category=IMPORT, description="a schema name pattern; must match the schema name as it is stored in the database; \"\" retrieves those without a schema; null means that the schema name should not be used to narrow the search") public String getSchemaPattern()
@TranslatorProperty(display="Schema Name", category=IMPORT, description="an exact schema name; must match the schema name as it is stored in the database; Takes precedence over schemaPatten if supplied.") public String getSchemaName()
@TranslatorProperty(display="Import Approximate Indexes", category=IMPORT, description="true to import approximate index information. when true, result is allowed to reflect approximate or out of data values; when false, results are requested to be accurate") public boolean isImportApproximateIndexes()
@TranslatorProperty(display="Widen unSigned Types", category=IMPORT, description="true to convert unsigned types to the next widest type. For example SQL Server reports tinyint as an unsigned type. With this option enabled, tinyint would be imported as a short instead of a byte.") public boolean isWidenUnsingedTypes()
@TranslatorProperty(display="Quote NameInSource", category=IMPORT, description="false will override the default and direct Teiid to create source queries using unquoted identifiers.") public boolean isQuoteNameInSource()
@TranslatorProperty(display="Use Procedure Specific Name", category=IMPORT, description="true will allow the import of overloaded procedures (which will normally result in a duplicate procedure error) by using the unique procedure specific name as the Teiid name. This option will only work with JDBC 4.0 compatible drivers that report specific names.") public boolean isUseProcedureSpecificName()
@TranslatorProperty(display="Use Catalog Name", category=IMPORT, description="true will use any non-null/non-empty catalog name as part of the name in source, e.g. \"catalog\".\"schema\".\"table\".\"column\", and in the Teiid runtime name if useFullSchemaName is also true. false will not use the catalog name in either the name in source or the Teiid runtime name. Should be set to false for sources that do not fully support a catalog concept, but return a non-null catalog name in their metadata - such as HSQL.") public boolean isUseCatalogName()
@TranslatorProperty(display="Auto Create Unique Constraints", category=IMPORT, description="true to create a unique constraint if one is not found for a foreign keys") public boolean isAutoCreateUniqueConstraints()
@TranslatorProperty(display="use Qualified Name", category=IMPORT, description="true will use name qualification for both the Teiid name and name in source as dictated by the useCatalogName and useFullSchemaName properties. Set to false to disable all qualification for both the Teiid name and the name in source, which effectively ignores the useCatalogName and useFullSchemaName properties. Note: when false this may lead to objects with duplicate names when importing from multiple schemas, which results in an exception.") public boolean isUseQualifiedName()
@TranslatorProperty(display="Use Any Index Cardinality", category=IMPORT, description="true will use the maximum cardinality returned from DatabaseMetaData.getIndexInfo. importKeys or importIndexes needs to be enabled for this setting to have an effect. This allows for better stats gathering from sources that don\'t support returning a statistical index.") public boolean isUseAnyIndexCardinality()
@TranslatorProperty(display="Import Statistics", category=IMPORT, description="true will use database dependent logic to determine the cardinality if none is determined. Not yet supported by all database types - currently only supported by Oracle and MySQL.") public boolean isImportStatistics()
@TranslatorProperty(display="Column Name Pattern", category=IMPORT, description="a column name pattern; must match the column name as it is stored in the database. Used to import columns of tables. Leave unset to import all columns.", advanced=true) public String getColumnNamePattern()
@TranslatorProperty(display="Exclude Tables", category=IMPORT, description="A case-insensitive regular expression that when matched against a fully qualified Teiid table name will exclude it from import. Applied after table names are retrieved. Use a negative look-ahead (?!<inclusion pattern>).* to act as an inclusion filter") public String getExcludeTables()
@TranslatorProperty(display="Exclude Procedures", category=IMPORT, description="A case-insensitive regular expression that when matched against a fully qualified Teiid procedure name will exclude it from import. Applied after procedure names are retrieved. Use a negative look-ahead (?!<inclusion pattern>).* to act as an inclusion filter") public String getExcludeProcedures()
public void setQuoteString(String quoteString)
public void setStartQuoteString(String quoteString)
public void setEndQuoteString(String quoteString)
@TranslatorProperty(display="Import RowId as binary", category=IMPORT, description="Import RowId values as varbinary rather than object.") public boolean isImportRowIdAsBinary()
public void setImportRowIdAsBinary(boolean importRowIdAsBinary)
@TranslatorProperty(display="Import Large as LOB", category=IMPORT, description="Import character and binary types larger than the Teiid max as clob or blob respectively.") public boolean isImportLargeAsLob()
public void setImportLargeAsLob(boolean importLargeAsLob)
@TranslatorProperty(display="Import Sequences", category=IMPORT, description="true to import sequences") public boolean isImportSequences()
public void setImportSequences(boolean importSequences)
@TranslatorProperty(display="Exclude Tables", category=IMPORT, description="A case-insensitive regular expression that when matched against a fully qualified Teiid sequence name will exclude it from import. Applied after table names are retrieved. Use a negative look-ahead (?!<inclusion pattern>).* to act as an inclusion filter") public String getExcludeSequences()
public void setExcludeSequences(String excludeSequences)
@TranslatorProperty(display="Sequence Name Pattern", category=IMPORT, description="a sequence name pattern; must match the sequence name as it is stored in the database") public String getSequenceNamePattern()
public void setSequenceNamePattern(String sequenceNamePattern)
@TranslatorProperty(display="Use Integral Types", category=IMPORT, description="Use integral types rather than decimal when the scale is 0.") public boolean isUseIntegralTypes()
public void setUseIntegralTypes(boolean useIntegralTypes)
protected boolean isHiddenSchema(String catalog, String schema)
catalog
- schema
- protected void getGeometryMetadata(Column c, Connection conn, String tableCatalog, String tableSchema, String tableName, String columnName)
c
- conn
- tableCatalog
- tableSchema
- tableName
- columnName
- protected void getGeographyMetadata(Column c, Connection conn, String tableCatalog, String tableSchema, String tableName, String columnName)
c
- conn
- tableCatalog
- tableSchema
- tableName
- columnName
- protected void getGeospatialMetadata(Column c, Connection conn, String tableCatalog, String tableSchema, String tableName, String columnName, Class<? extends AbstractGeospatialType> clazz)
protected String getGeographyMetadataTableName()
protected String getGeometryMetadataTableName()
Copyright © 2019. All rights reserved.