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
  • Constructor Details

    • BasicJDBCMetadataProvider

      public BasicJDBCMetadataProvider()
      Creates a new BasicJDBCMetadataProvider instance.
      Since:
      3.0
  • Method Details

    • setContext

      public void setContext(JDBCContext context)
      Sets the JDBCContext.
      Specified by:
      setContext in interface JDBCMetadataProvider
      Parameters:
      context - JDBCContext
      Since:
      3.0
    • getContext

      public JDBCContext getContext()
      Returns the JDBCContext.
      Returns:
      a JDBCContext instance
      Since:
      3.0
    • getMetadata

      public MetadataItem[] getMetadata(MetadataItem[] path) throws InvalidMetadataPath, SQLException
      Returns a list of MetadataItem objects that corresponds to the given path.
      Specified by:
      getMetadata in interface JDBCMetadataProvider
      Parameters:
      path - a path of MetadataItem objects.
      Returns:
      a list of MetadataItem objects.
      Throws:
      InvalidMetadataPath - if the given path is invalid
      SQLException - 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 supported
      SQLException - 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 supported
      SQLException - 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 invalid
      SQLException - if a database error occurs
      Since:
      3.0
    • getTableAliases

      protected MetadataItem[] getTableAliases(String catalog, String schema)
      Parameters:
      catalog - catalog
      schema - 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 invalid
      SQLException - if a database error occurs
      Since:
      3.0
    • getProcedures

      protected MetadataItem[] getProcedures(String catalog, String schema) throws SQLException
      Parameters:
      catalog - catalog
      schema - 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 - catalog
      schema - schema
      procedure - 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 - DatabaseMetaData
      catalog - catalog
      Throws:
      SQLException - if a database error occurs
      InvalidMetadataPath - 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 - DatabaseMetaData
      catalog - catalog
      schema - schema
      Throws:
      SQLException - if a database error occurs
      InvalidMetadataPath - 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 - DatabaseMetaData
      catalog - catalog
      schema - schema
      table - table
      Throws:
      SQLException - if a database error occurs
      InvalidMetadataPath - 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 name
      type - a column type
      typeName - data source dependent type name
      description - 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 name
      jdbcType - a JDBC type
      typeName - data source dependent type name
      precision - a precision, used for numeric types
      scale - a scale, used for numeric types
      description - comment describing column
      Returns:
      a column item
      Since:
      3.0
      See Also:
    • 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 interface JDBCMetadataProvider
      Parameters:
      jdbcType - jdbcType
      typeName - typeName
      precision - precision
      scale - scale
      Returns:
      Class
      Since:
      3.0
      See Also:
    • 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 interface JDBCMetadataProvider
      Parameters:
      c - a Java type
      Returns:
      a JDBC type
      Since:
      3.0
      See Also:
    • 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