Package com.spotfire.ws.im.ds.sql
Class BasicJDBCMetadataProvider
java.lang.Object
com.spotfire.ws.im.ds.sql.BasicJDBCMetadataProvider
- All Implemented Interfaces:
JDBCMetadataProvider
A basic implementation of the JDBCMetadataProvider interface.
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newBasicJDBCMetadataProviderinstance. -
Method Summary
Modifier and TypeMethodDescriptioncreateCatalogItem(String name) Creates a catalog item.createColumnItem(String name, int jdbcType, String typeName, int precision, int scale, String description) Creates a column item.createColumnItem(String name, Class type, String typeName, String description) Creates a column item.createSchemaItem(String name) Creates a schema item.createTableItem(String name) Creates a table item.protected MetadataItem[]Returns a list of catalog items.protected MetadataItem[]getColumns(String catalog, String schema, String table) Returns a list of column items.Returns theJDBCContext.getMetadata(MetadataItem[] path) Returns a list ofMetadataItemobjects that corresponds to the given path.protected ProcedureMetadatagetProcedureMetadata(String catalog, String schema, String procedure) protected MetadataItem[]getProcedures(String catalog, String schema) protected MetadataItem[]getSchemas(String catalog) Returns a list of schema items.protected MetadataItem[]getTableAliases(String catalog, String schema) protected MetadataItem[]Returns a list of table items.voidsetContext(JDBCContext context) Sets theJDBCContext.static MetadataItem[]sortMetadataItemsByName(MetadataItem[] items) protected static MetadataItem[]sortMetadataItemsByName(List<MetadataItem> items) toJavaType(int jdbcType, String typeName, int precision, int scale) Converts a JDBC type to a Java type.inttoJDBCType(Class c) Converts a Java type to a JDBC type.protected voidverifyCatalog(DatabaseMetaData dbmd, String catalog) protected voidverifySchema(DatabaseMetaData dbmd, String catalog, String schema) protected voidverifyTable(DatabaseMetaData dbmd, String catalog, String schema, String table)
-
Constructor Details
-
BasicJDBCMetadataProvider
public BasicJDBCMetadataProvider()Creates a newBasicJDBCMetadataProviderinstance.- Since:
- 3.0
-
-
Method Details
-
setContext
Sets theJDBCContext.- Specified by:
setContextin interfaceJDBCMetadataProvider- Parameters:
context- JDBCContext- Since:
- 3.0
-
getContext
Returns theJDBCContext.- Returns:
- a
JDBCContextinstance - Since:
- 3.0
-
getMetadata
Returns a list ofMetadataItemobjects that corresponds to the given path.- Specified by:
getMetadatain interfaceJDBCMetadataProvider- Parameters:
path- a path ofMetadataItemobjects.- Returns:
- a list of
MetadataItemobjects. - Throws:
InvalidMetadataPath- if the given path is invalidSQLException- if a database error occurs- Since:
- 3.0
-
getCatalogs
Returns a list of catalog items.- Returns:
- a list of catalog items
- Throws:
InvalidMetadataPath- if the catalog level is not supportedSQLException- if a database error occurs- Since:
- 3.0
-
getSchemas
Returns a list of schema items.- Parameters:
catalog- a catalog name, may be ""- Returns:
- a list of schema items
- Throws:
InvalidMetadataPath- if the catalog is invalid or if the schema level is not supportedSQLException- if a database error occurs- Since:
- 3.0
-
getTables
protected MetadataItem[] getTables(String catalog, String schema) throws InvalidMetadataPath, SQLException Returns a list of table items.- Parameters:
catalog- a catalog name, may be ""schema- a schema name, may be ""- Returns:
- a list of table items
- Throws:
InvalidMetadataPath- if the given catalog or schema is invalidSQLException- if a database error occurs- Since:
- 3.0
-
getTableAliases
- Parameters:
catalog- catalogschema- schema- Returns:
- MetadataItem
- Since:
- 3.0
-
getColumns
protected MetadataItem[] getColumns(String catalog, String schema, String table) throws InvalidMetadataPath, SQLException Returns a list of column items.- Parameters:
catalog- a catalog name, may be ""schema- a schema name, may be ""table- a table name, may be ""- Returns:
- a list of column items
- Throws:
InvalidMetadataPath- if the given catalog, schema or table is invalidSQLException- if a database error occurs- Since:
- 3.0
-
getProcedures
- Parameters:
catalog- catalogschema- schema- Returns:
- MetadataItem
- Throws:
SQLException- if a database error occurs- Since:
- 3.0
-
getProcedureMetadata
protected ProcedureMetadata getProcedureMetadata(String catalog, String schema, String procedure) throws SQLException - Parameters:
catalog- catalogschema- schemaprocedure- procedure- Returns:
- ProcedureMetadata
- Throws:
SQLException- if a database error occurs- Since:
- 3.0
-
verifyCatalog
protected void verifyCatalog(DatabaseMetaData dbmd, String catalog) throws InvalidMetadataPath, SQLException - Parameters:
dbmd- DatabaseMetaDatacatalog- catalog- Throws:
SQLException- if a database error occursInvalidMetadataPath- if the given catalog is not valid.- Since:
- 3.0
-
verifySchema
protected void verifySchema(DatabaseMetaData dbmd, String catalog, String schema) throws InvalidMetadataPath, SQLException - Parameters:
dbmd- DatabaseMetaDatacatalog- catalogschema- schema- Throws:
SQLException- if a database error occursInvalidMetadataPath- if a given schema is invalid- Since:
- 3.0
-
verifyTable
protected void verifyTable(DatabaseMetaData dbmd, String catalog, String schema, String table) throws InvalidMetadataPath, SQLException - Parameters:
dbmd- DatabaseMetaDatacatalog- catalogschema- schematable- table- Throws:
SQLException- if a database error occursInvalidMetadataPath- if a given table is invalid- Since:
- 3.0
-
createCatalogItem
Creates a catalog item.- Parameters:
name- a catalog name- Returns:
- a catalog item
- Since:
- 3.0
-
createSchemaItem
Creates a schema item.- Parameters:
name- a schema name- Returns:
- a schema item
- Since:
- 3.0
-
createTableItem
Creates a table item.- Parameters:
name- a table name- Returns:
- a table item
- Since:
- 3.0
-
createColumnItem
Creates a column item.- Parameters:
name- a column nametype- a column typetypeName- data source dependent type namedescription- comment describing column- Returns:
- a column item
- Since:
- 3.0
- See Also:
-
createColumnItem
public MetadataItem createColumnItem(String name, int jdbcType, String typeName, int precision, int scale, String description) Creates a column item.- Parameters:
name- a column namejdbcType- a JDBC typetypeName- data source dependent type nameprecision- a precision, used for numeric typesscale- a scale, used for numeric typesdescription- comment describing column- Returns:
- a column item
- Since:
- 3.0
- See Also:
-
toJavaType
Description copied from interface:JDBCMetadataProviderConverts a JDBC type to a Java type.The following Java types are supported:
StringIntegerLongFloatDoublecom.spotfire.ws.dat.Datecom.spotfire.ws.dat.Timecom.spotfire.ws.dat.DateTimecom.spotfire.ws.dat.Clobcom.spotfire.ws.dat.Blob
- Specified by:
toJavaTypein interfaceJDBCMetadataProvider- Parameters:
jdbcType- jdbcTypetypeName- typeNameprecision- precisionscale- scale- Returns:
- Class
- Since:
- 3.0
- See Also:
-
toJDBCType
Description copied from interface:JDBCMetadataProviderConverts a Java type to a JDBC type.The following Java types must be supported:
StringIntegerLongFloatDoublecom.spotfire.ws.dat.Datecom.spotfire.ws.dat.Timecom.spotfire.ws.dat.DateTimecom.spotfire.ws.dat.Clobcom.spotfire.ws.dat.Blob
- Specified by:
toJDBCTypein interfaceJDBCMetadataProvider- Parameters:
c- a Java type- Returns:
- a JDBC type
- Since:
- 3.0
- See Also:
-
sortMetadataItemsByName
- Parameters:
items- items- Returns:
- MetadataItem
- Since:
- 3.0
-
sortMetadataItemsByName
- Parameters:
items- the items- Returns:
- the meta data item
- Since:
- 10.1
-