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
ConstructorDescriptionCreates a newBasicJDBCMetadataProvider
instance. -
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 ofMetadataItem
objects that corresponds to the given path.protected ProcedureMetadata
getProcedureMetadata
(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.void
setContext
(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.int
toJDBCType
(Class c) Converts a Java type to a JDBC type.protected void
verifyCatalog
(DatabaseMetaData dbmd, String catalog) protected void
verifySchema
(DatabaseMetaData dbmd, String catalog, String schema) protected void
verifyTable
(DatabaseMetaData dbmd, String catalog, String schema, String table)
-
Constructor Details
-
BasicJDBCMetadataProvider
public BasicJDBCMetadataProvider()Creates a newBasicJDBCMetadataProvider
instance.- Since:
- 3.0
-
-
Method Details
-
setContext
Sets theJDBCContext
.- Specified by:
setContext
in interfaceJDBCMetadataProvider
- Parameters:
context
- JDBCContext- Since:
- 3.0
-
getContext
Returns theJDBCContext
.- Returns:
- a
JDBCContext
instance - Since:
- 3.0
-
getMetadata
Returns a list ofMetadataItem
objects that corresponds to the given path.- Specified by:
getMetadata
in interfaceJDBCMetadataProvider
- Parameters:
path
- a path ofMetadataItem
objects.- Returns:
- a list of
MetadataItem
objects. - 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:JDBCMetadataProvider
Converts a JDBC type to a Java type.The following Java types are supported:
String
Integer
Long
Float
Double
com.spotfire.ws.dat.Date
com.spotfire.ws.dat.Time
com.spotfire.ws.dat.DateTime
com.spotfire.ws.dat.Clob
com.spotfire.ws.dat.Blob
- Specified by:
toJavaType
in interfaceJDBCMetadataProvider
- Parameters:
jdbcType
- jdbcTypetypeName
- typeNameprecision
- precisionscale
- scale- Returns:
- Class
- Since:
- 3.0
- See Also:
-
toJDBCType
Description copied from interface:JDBCMetadataProvider
Converts a Java type to a JDBC type.The following Java types must be supported:
String
Integer
Long
Float
Double
com.spotfire.ws.dat.Date
com.spotfire.ws.dat.Time
com.spotfire.ws.dat.DateTime
com.spotfire.ws.dat.Clob
com.spotfire.ws.dat.Blob
- Specified by:
toJDBCType
in 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
-