OptionalTool
public class ForeignDBViews extends java.lang.Object implements OptionalTool
OptionalTool to create wrapper functions and views for all of the user tables in a foreign database.
Modifier and Type | Field | Description |
---|---|---|
private static java.lang.String[] |
SAFE_DROP_SQLSTATES |
|
private static int |
XML_TYPE |
Constructor | Description |
---|---|
ForeignDBViews() |
0-arg constructor required by the OptionalTool contract
|
Modifier and Type | Method | Description |
---|---|---|
private void |
createDerbySchema(java.sql.Connection derbyConn,
java.lang.String derbySchemaName) |
Create a Derby schema if it does not already exist.
|
private java.lang.String |
delimitedID(java.lang.String text) |
|
private java.lang.String |
dotSeparatedSchemaName(java.lang.String rawName) |
Turn a Derby schema name into a schema name suitable for use
in a dot-separated object name.
|
private void |
dropDerbySchema(java.sql.Connection derbyConn,
java.lang.String derbySchemaName) |
Drop a Derby schema.
|
private void |
dropObject(java.sql.Connection conn,
java.lang.String schemaName,
java.lang.String objectName,
java.lang.String objectType,
boolean restrict) |
Drop a schema object.
|
private void |
executeDDL(java.sql.Connection conn,
java.lang.String text) |
|
private java.sql.Connection |
getDerbyConnection() |
|
private java.lang.String |
getDerbySchemaName(java.lang.String schemaPrefix,
java.lang.String foreignSchemaName) |
Get the name of the local Derby schema corresponding to a foreign schema name.
|
private java.sql.Connection |
getForeignConnection(java.lang.String connectionURL) |
|
private java.sql.ResultSet |
getForeignTables(java.sql.DatabaseMetaData foreignDBMD) |
Get a cursor through the user tables in the foreign database.
|
void |
loadTool(java.lang.String... configurationParameters) |
Creates a local Derby schema for every foreign schema which contains
a user table.
|
private java.lang.String |
mapType(int jdbcType,
int precision,
int scale,
java.lang.String foreignTypeName) |
Get the type of an external database's column as a Derby type name.
|
private java.lang.String |
precisionAndScale(int precision,
int scale) |
Build a precision and scale designator.
|
private java.lang.String |
precisionToLength(int precision) |
Turns precision into a length designator.
|
private java.sql.PreparedStatement |
prepareStatement(java.sql.Connection conn,
java.lang.String text) |
|
private void |
registerForeignTable(java.sql.DatabaseMetaData foreignDBMD,
java.lang.String foreignSchemaName,
java.lang.String foreignTableName,
java.lang.String foreignConnectionURL,
java.lang.String schemaPrefix,
java.sql.Connection derbyConn) |
|
private java.lang.String |
stringLiteral(java.lang.String text) |
|
void |
unloadTool(java.lang.String... configurationParameters) |
Removes the schemas, table functions, and views created by loadTool().
|
private java.sql.SQLException |
wrap(java.lang.String errorMessage) |
private static final int XML_TYPE
private static final java.lang.String[] SAFE_DROP_SQLSTATES
public ForeignDBViews()
public void loadTool(java.lang.String... configurationParameters) throws java.sql.SQLException
Creates a local Derby schema for every foreign schema which contains a user table. Then creates a table function and convenience view for every user table found in the foreign database. The parameters to this method are:
loadTool
in interface OptionalTool
java.sql.SQLException
public void unloadTool(java.lang.String... configurationParameters) throws java.sql.SQLException
Removes the schemas, table functions, and views created by loadTool().
unloadTool
in interface OptionalTool
java.sql.SQLException
private void registerForeignTable(java.sql.DatabaseMetaData foreignDBMD, java.lang.String foreignSchemaName, java.lang.String foreignTableName, java.lang.String foreignConnectionURL, java.lang.String schemaPrefix, java.sql.Connection derbyConn) throws java.sql.SQLException
java.sql.SQLException
private java.sql.ResultSet getForeignTables(java.sql.DatabaseMetaData foreignDBMD) throws java.sql.SQLException
Get a cursor through the user tables in the foreign database.
java.sql.SQLException
private void createDerbySchema(java.sql.Connection derbyConn, java.lang.String derbySchemaName) throws java.sql.SQLException
Create a Derby schema if it does not already exist.
java.sql.SQLException
private void dropDerbySchema(java.sql.Connection derbyConn, java.lang.String derbySchemaName) throws java.sql.SQLException
Drop a Derby schema.
java.sql.SQLException
private java.lang.String getDerbySchemaName(java.lang.String schemaPrefix, java.lang.String foreignSchemaName)
Get the name of the local Derby schema corresponding to a foreign schema name. Returns null if the default (current) schema is to be used.
private java.lang.String dotSeparatedSchemaName(java.lang.String rawName)
Turn a Derby schema name into a schema name suitable for use in a dot-separated object name.
private java.lang.String mapType(int jdbcType, int precision, int scale, java.lang.String foreignTypeName) throws java.sql.SQLException
Get the type of an external database's column as a Derby type name.
java.sql.SQLException
private java.lang.String precisionToLength(int precision)
Turns precision into a length designator.
private java.lang.String precisionAndScale(int precision, int scale)
Build a precision and scale designator.
private void dropObject(java.sql.Connection conn, java.lang.String schemaName, java.lang.String objectName, java.lang.String objectType, boolean restrict) throws java.sql.SQLException
Drop a schema object. If the object does not exist, silently swallow the error.
java.sql.SQLException
private java.sql.Connection getForeignConnection(java.lang.String connectionURL) throws java.sql.SQLException
java.sql.SQLException
private java.sql.Connection getDerbyConnection() throws java.sql.SQLException
java.sql.SQLException
private java.lang.String delimitedID(java.lang.String text)
private java.lang.String stringLiteral(java.lang.String text)
private void executeDDL(java.sql.Connection conn, java.lang.String text) throws java.sql.SQLException
java.sql.SQLException
private java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, java.lang.String text) throws java.sql.SQLException
java.sql.SQLException
private java.sql.SQLException wrap(java.lang.String errorMessage)
Apache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.