Package com.spotfire.ws.im.ds.sql
Class BasicJDBCMetadataProvider
- java.lang.Object
-
- com.spotfire.ws.im.ds.sql.BasicJDBCMetadataProvider
-
- All Implemented Interfaces:
JDBCMetadataProvider
public class BasicJDBCMetadataProvider extends Object implements JDBCMetadataProvider
A basic implementation of the
JDBCMetadataProvider
interface.- Since:
- 3.0
- Version:
- $Revision$
- Author:
- Magnus Rylander
-
-
Constructor Summary
Constructors Constructor Description BasicJDBCMetadataProvider()
Creates a newBasicJDBCMetadataProvider
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MetadataItem
createCatalogItem(String name)
Creates a catalog item.MetadataItem
createColumnItem(String name, int jdbcType, String typeName, int precision, int scale, String description)
Creates a column item.MetadataItem
createColumnItem(String name, Class type, String typeName, String description)
Creates a column item.MetadataItem
createSchemaItem(String name)
Creates a schema item.MetadataItem
createTableItem(String name)
Creates a table item.protected MetadataItem[]
getCatalogs()
Returns a list of catalog items.protected MetadataItem[]
getColumns(String catalog, String schema, String table)
Returns a list of column items.JDBCContext
getContext()
Returns theJDBCContext
.MetadataItem[]
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[]
getTables(String catalog, String schema)
Returns a list of table items.void
setContext(JDBCContext context)
Sets theJDBCContext
.static MetadataItem[]
sortMetadataItemsByName(MetadataItem[] items)
protected static MetadataItem[]
sortMetadataItemsByName(List<MetadataItem> items)
Class
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)
-
-
-
Method Detail
-
setContext
public void setContext(JDBCContext context)
Sets theJDBCContext
.- Specified by:
setContext
in interfaceJDBCMetadataProvider
- Parameters:
context
- JDBCContext- Since:
- 3.0
-
getContext
public JDBCContext getContext()
Returns theJDBCContext
.- Returns:
- a
JDBCContext
instance - Since:
- 3.0
-
getMetadata
public MetadataItem[] getMetadata(MetadataItem[] path) throws InvalidMetadataPath, SQLException
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
protected MetadataItem[] getCatalogs() throws InvalidMetadataPath, SQLException
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
protected MetadataItem[] getSchemas(String catalog) throws InvalidMetadataPath, SQLException
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
protected MetadataItem[] getTableAliases(String catalog, String schema)
- 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
protected MetadataItem[] getProcedures(String catalog, String schema) throws SQLException
- 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
public MetadataItem createCatalogItem(String name)
Creates a catalog item.- Parameters:
name
- a catalog name- Returns:
- a catalog item
- Since:
- 3.0
-
createSchemaItem
public MetadataItem createSchemaItem(String name)
Creates a schema item.- Parameters:
name
- a schema name- Returns:
- a schema item
- Since:
- 3.0
-
createTableItem
public MetadataItem createTableItem(String name)
Creates a table item.- Parameters:
name
- a table name- Returns:
- a table item
- Since:
- 3.0
-
createColumnItem
public MetadataItem createColumnItem(String name, Class type, String typeName, String description)
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:
toJavaType(int, java.lang.String, int, int)
-
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(int, java.lang.String, int, int)
-
toJavaType
public Class toJavaType(int jdbcType, String typeName, int precision, int scale)
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:
Types
-
toJDBCType
public int toJDBCType(Class c)
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:
Types
-
sortMetadataItemsByName
public static MetadataItem[] sortMetadataItemsByName(MetadataItem[] items)
- Parameters:
items
- items- Returns:
- MetadataItem
- Since:
- 3.0
-
sortMetadataItemsByName
protected static MetadataItem[] sortMetadataItemsByName(List<MetadataItem> items)
- Parameters:
items
- the items- Returns:
- the meta data item
- Since:
- 10.1
-
-