public class JdbcSchema extends Object
The structure of this information is as follows: A database has tables. A table has columnIter. A column has one or more usages. A usage might be a column being used as a foreign key or as part of a measure.
Tables are created when calling code requests the set of available
tables. This call getTables()
causes all tables to be loaded.
But a table's columnIter are not loaded until, on a table-by-table basis,
a request is made to get the set of columnIter associated with the table.
Since, the AggTableManager first attempts table name matches (recognition)
most tables do not match, so why load their columnIter.
Of course, as a result, there are a host of methods that can throw an
SQLException
, rats.
Modifier and Type | Class and Description |
---|---|
static interface |
JdbcSchema.Factory |
static class |
JdbcSchema.StdFactory |
class |
JdbcSchema.Table
A table in a database.
|
static class |
JdbcSchema.UsageType
Enumeration of ways that an aggregate table can use a column.
|
Modifier and Type | Field and Description |
---|---|
static String |
FACT_COUNT_COLUMN_NAME |
static int |
FACT_COUNT_COLUMN_USAGE |
static String |
FOREIGN_KEY_COLUMN_NAME |
static int |
FOREIGN_KEY_COLUMN_USAGE |
static String |
IGNORE_COLUMN_NAME |
static int |
IGNORE_COLUMN_USAGE |
static String |
LEVEL_COLUMN_NAME |
static int |
LEVEL_COLUMN_USAGE |
static String |
MEASURE_COLUMN_NAME |
static int |
MEASURE_COLUMN_USAGE |
static String |
UNKNOWN_COLUMN_NAME |
static int |
UNKNOWN_COLUMN_USAGE |
Modifier and Type | Method and Description |
---|---|
protected void |
addTable(ResultSet rs)
Makes a Table from an ResultSet: the table's name is the ResultSet third
entry.
|
protected void |
clear() |
static void |
clearAllDBs() |
static void |
clearDB(DataSource dataSource)
Clears information in a JdbcSchema associated with a DataSource.
|
static String |
convertColumnTypeToName(Set<JdbcSchema.UsageType> columnType)
Maps from column type enum to column type name or list of names if the
parameter represents more than on usage.
|
void |
flushUsages()
flushes all star usage references
|
String |
getCatalogName()
Returns the database's catalog name.
|
DataSource |
getDataSource() |
static Dialect.Datatype |
getDatatype(int javaType)
Converts a
Types value to a
Dialect.Datatype . |
org.apache.log4j.Logger |
getLogger()
Returns the Logger.
|
String |
getSchemaName()
Returns the database's schema name.
|
JdbcSchema.Table |
getTable(String tableName)
Gets a table by name.
|
Collection<JdbcSchema.Table> |
getTables()
Returns the database's tables.
|
static boolean |
isText(int javaType)
Returns true if the parameter is a java.sql.Type text type.
|
static boolean |
isUniqueColumnType(Set<JdbcSchema.UsageType> columnType)
Determine if the parameter represents a single column type, i.e., the
column only has one usage.
|
void |
load()
This forces the tables to be loaded.
|
static JdbcSchema |
makeDB(DataSource dataSource)
Creates or retrieves an instance of the JdbcSchema for the given
DataSource.
|
void |
print(PrintWriter pw,
String prefix) |
protected void |
remove() |
static void |
removeDB(DataSource dataSource)
Removes a JdbcSchema associated with a DataSource.
|
void |
setCatalogName(String catalog)
Sets the database's catalog name.
|
protected void |
setDataSource(DataSource dataSource) |
void |
setSchemaName(String schema)
Sets the database's schema name.
|
String |
toString() |
public static final int UNKNOWN_COLUMN_USAGE
public static final int FOREIGN_KEY_COLUMN_USAGE
public static final int MEASURE_COLUMN_USAGE
public static final int LEVEL_COLUMN_USAGE
public static final int FACT_COUNT_COLUMN_USAGE
public static final int IGNORE_COLUMN_USAGE
public static final String UNKNOWN_COLUMN_NAME
public static final String FOREIGN_KEY_COLUMN_NAME
public static final String MEASURE_COLUMN_NAME
public static final String LEVEL_COLUMN_NAME
public static final String FACT_COUNT_COLUMN_NAME
public static final String IGNORE_COLUMN_NAME
public org.apache.log4j.Logger getLogger()
public static JdbcSchema makeDB(DataSource dataSource)
dataSource
- DataSourcepublic static void clearDB(DataSource dataSource)
dataSource
- DataSourcepublic static void removeDB(DataSource dataSource)
dataSource
- DataSourcepublic static boolean isUniqueColumnType(Set<JdbcSchema.UsageType> columnType)
columnType
- Column typespublic static String convertColumnTypeToName(Set<JdbcSchema.UsageType> columnType)
public static Dialect.Datatype getDatatype(int javaType)
Types
value to a
Dialect.Datatype
.javaType
- JDBC type code, as per Types
public static boolean isText(int javaType)
public void load() throws SQLException
SQLException
protected void clear()
protected void remove()
public DataSource getDataSource()
protected void setDataSource(DataSource dataSource)
public void setSchemaName(String schema)
schema
- Schema namepublic String getSchemaName()
public void setCatalogName(String catalog)
public String getCatalogName()
public Collection<JdbcSchema.Table> getTables()
public void flushUsages()
public JdbcSchema.Table getTable(String tableName)
public void print(PrintWriter pw, String prefix)
protected void addTable(ResultSet rs) throws SQLException
rs
- Result setSQLException
public static void clearAllDBs()
Copyright © 2018 Hitachi Vantara. All rights reserved.