|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.plugin.FarragoAbstractPluginBase net.sf.farrago.namespace.impl.MedAbstractBase net.sf.farrago.namespace.impl.MedAbstractDataServer net.sf.farrago.namespace.jdbc.MedJdbcDataServer
public class MedJdbcDataServer
MedJdbcDataServer implements the FarragoMedDataServer
interface for
JDBC data.
MedJdbcDataServer provides three modes of operation:
DataSource
object from JNDI and obtains database connections from it. The DataSource is
assumed to represent a connection pool. Validation queries and login timeouts
are the responsibility of the data source. When getConnection()
(or
getDatabaseMetaData()
) are invoked, a single Connection
is
borrowed from the pool and held until releaseResources()
or closeAllocation()
is invoked. A separate Connection is borrowed from the
pool for each call to getRuntimeSupport(Object)
and is returned when
the associated FarragoStatementAllocation
object is closed.getConnection()
(or
getDatabaseMetaData()
) are invoked, a single Connection
is
borrowed from the pool and held until releaseResources()
or closeAllocation()
is invoked. A separate Connection is borrowed from the
pool for each call to getRuntimeSupport(Object)
and is returned when
the associated FarragoStatementAllocation
object is closed.disabled
, MedJdbcDataServer behaves as
it did before the introduction of connection pooling. A single Connection
is obtained using the DriverManager
. Validation queries
are executed when the Connection is next used after a call to releaseResources()
. The same Connection is also used for getRuntimeSupport(Object)
. The Connection is held until closeAllocation()
is invoked.
Nested Class Summary | |
---|---|
private static class |
MedJdbcDataServer.CustomPoolableConnection
|
private class |
MedJdbcDataServer.CustomPoolableConnectionFactory
CustomPoolableConnectionFactory is similar to DBCP's PoolableConnectionFactory , but allows us to better control when Connection.setAutoCommit(boolean) and Connection.setReadOnly(boolean) are called. |
static class |
MedJdbcDataServer.Source
|
static class |
MedJdbcDataServer.WildcardMapping
|
Fields inherited from class net.sf.farrago.plugin.FarragoAbstractPluginBase |
---|
BOOLEAN_CHOICES_DEFAULT_FALSE, BOOLEAN_CHOICES_DEFAULT_TRUE, EMPTY_DRIVER_PROPERTIES |
Fields inherited from interface net.sf.farrago.namespace.FarragoMedDataServer |
---|
PROP_SERVER_NAME, PROP_SERVER_TYPE, PROP_SERVER_VERSION |
Constructor Summary | |
---|---|
protected |
MedJdbcDataServer(String serverMofId,
Properties props)
|
Method Summary | |
---|---|
void |
closeAllocation()
Closes this object. |
private void |
closeConnection()
|
private void |
createSchemaMaps(DatabaseMetaData databaseMetaData,
String key,
String value)
|
private void |
createTableMaps(String srcSchema,
String srcTable,
String targetSchema,
String targetTable)
|
private void |
createTablePrefixMaps(String srcSchema,
String srcTablePrefix,
String targetSchema,
String targetTablePrefix)
|
String |
getCatalogName()
|
protected Connection |
getConnection()
Retrieves a Connection to this data server's configured database. |
protected DatabaseMetaData |
getDatabaseMetaData()
Retrieves database metadata for this data server's configured database. |
FarragoMedNameDirectory |
getNameDirectory()
Gets a FarragoMedNameDirectory corresponding to this server. |
protected String |
getPassword()
Retrieves the configured password for this data server. |
Object |
getRuntimeSupport(Object param)
Gets an object needed for runtime support. |
protected MedJdbcNameDirectory |
getSchemaNameDirectory()
|
protected String |
getUserName()
Retrieves the configured user name for this data server. |
void |
initialize()
|
private void |
initializeDataSource()
|
private void |
initMetaData()
|
private boolean |
isQuoteChar(String mapping,
int index)
|
private void |
markLoopbackConnection(Connection conn)
|
FarragoMedColumnSet |
newColumnSet(String[] localName,
Properties tableProps,
FarragoTypeFactory typeFactory,
RelDataType rowType,
Map<String,Properties> columnPropMap)
Creates an instance of a FarragoMedColumnSet corresponding to row data identified by properties rather than container name. |
private Connection |
newConnection()
Retrieves a Connection object from the DataSource and set auto-commit mode if necessary. |
private void |
parseMapping(DatabaseMetaData databaseMetaData,
String mapping,
boolean isTableMapping,
boolean isTablePrefixMapping)
|
void |
registerRelMetadataProviders(ChainedRelMetadataProvider chain)
Gives this wrapper a chance to register one or more RelMetadataProvider s in the chain which will be used to answer
relational expression metadata queries during optimization. |
void |
registerRules(RelOptPlanner planner)
Gives this wrapper a chance to register any special optimization rules. |
void |
releaseResources()
Gives this wrapper a chance to release any resources. |
protected static void |
removeNonDriverProps(Properties props)
|
Methods inherited from class net.sf.farrago.namespace.impl.MedAbstractDataServer |
---|
getLoopbackDataSource, getProperties, getServerMofId, setLoopbackDataSource |
Methods inherited from class net.sf.farrago.plugin.FarragoAbstractPluginBase |
---|
getBooleanProperty, getByteProperty, getDoubleProperty, getFloatProperty, getIntProperty, getLongProperty, getShortProperty, requireProperty |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROP_URL
public static final String PROP_DRIVER_CLASS
public static final String PROP_USER_NAME
public static final String PROP_PASSWORD
public static final String PROP_JNDI_NAME
public static final String PROP_CATALOG_NAME
public static final String PROP_SCHEMA_NAME
public static final String PROP_TABLE_NAME
public static final String PROP_OBJECT
public static final String PROP_TABLE_TYPES
public static final String PROP_EXT_OPTIONS
public static final String PROP_TYPE_SUBSTITUTION
public static final String PROP_TYPE_MAPPING
public static final String PROP_LOGIN_TIMEOUT
public static final String PROP_VALIDATION_QUERY
public static final String PROP_FETCH_SIZE
public static final String PROP_AUTOCOMMIT
public static final String PROP_USE_SCHEMA_NAME_AS_FOREIGN_QUALIFIER
public static final String PROP_LENIENT
public static final String PROP_SKIP_TYPE_CHECK
public static final String PROP_DISABLED_PUSHDOWN_REL_PATTERN
public static final String PROP_SCHEMA_MAPPING
public static final String PROP_TABLE_MAPPING
public static final String PROP_TABLE_PREFIX_MAPPING
public static final String PROP_MAX_IDLE_CONNECTIONS
public static final String PROP_EVICTION_TIMER_PERIOD_MILLIS
public static final String PROP_MIN_EVICTION_IDLE_MILLIS
public static final String PROP_VALIDATION_TIMING
public static final String PROP_VALIDATION_TIMING_ON_BORROW
public static final String PROP_VALIDATION_TIMING_ON_RETURN
public static final String PROP_VALIDATION_TIMING_WHILE_IDLE
public static final String PROP_DISABLE_CONNECTION_POOL
public static final String PROP_VERSION
public static final String PROP_NAME
public static final String PROP_TYPE
public static final boolean DEFAULT_USE_SCHEMA_NAME_AS_FOREIGN_QUALIFIER
public static final boolean DEFAULT_LENIENT
public static final boolean DEFAULT_SKIP_TYPE_CHECK
public static final String DEFAULT_DISABLED_PUSHDOWN_REL_PATTERN
public static final int DEFAULT_FETCH_SIZE
public static final boolean DEFAULT_AUTOCOMMIT
public static final int DEFAULT_MAX_IDLE_CONNECTIONS
public static final long DEFAULT_EVICTION_TIMER_PERIOD
public static final long DEFAULT_MIN_EVICTION_IDLE_MILLIS
public static final String DEFAULT_VALIDATION_TIMING
public static final boolean DEFAULT_DISABLE_CONNECTION_POOL
private static final Logger logger
protected DataSource dataSource
protected Properties connectProps
protected String userName
protected String password
protected String url
private org.apache.commons.pool.impl.GenericObjectPool connectionPool
private int maxIdleConnections
private long evictionTimerPeriodMillis
private long minEvictionIdleMillis
protected String jndiName
private Connection connection
protected boolean supportsMetaData
private DatabaseMetaData databaseMetaData
private boolean disableConnectionPool
private boolean validateConnection
disableConnectionPool
is true, used to determine when to
re-validate the connection.
protected String catalogName
protected String schemaName
protected String[] tableTypes
protected String loginTimeout
protected String validationQuery
private boolean validateOnBorrow
private boolean validateOnReturn
private boolean validateWhileIdle
protected boolean useSchemaNameAsForeignQualifier
protected boolean lenient
protected boolean skipTypeCheck
protected Pattern disabledPushdownPattern
private int fetchSize
private boolean autocommit
protected HashMap<String,Map<String,String>> schemaMaps
protected HashMap<String,Map<String,MedJdbcDataServer.Source>> tableMaps
protected Map<String,List<MedJdbcDataServer.WildcardMapping>> tablePrefixMaps
Constructor Detail |
---|
protected MedJdbcDataServer(String serverMofId, Properties props)
Method Detail |
---|
public void initialize() throws SQLException
SQLException
public String getCatalogName()
private void initMetaData()
private void initializeDataSource() throws SQLException
SQLException
protected String getUserName()
protected String getPassword()
protected Connection getConnection() throws SQLException
releaseResources()
is invoked.
This Connection is not to be used for runtime query support, although DDL (such as IMPORT FOREIGN SCHEMA) may use it.
NOTE: if connection pooling is disabled
, the Connection returned by this
method will be re-used for runtime support and will be returned even
after a call to releaseResources()
.
SQLException
- if there's an error obtaining a connectionprivate Connection newConnection() throws SQLException
SQLException
private void markLoopbackConnection(Connection conn)
protected DatabaseMetaData getDatabaseMetaData() throws SQLException
getConnection()
to obtain a
Connection to the database. The same DatabaseMetaData
object will
be returned for each call to this method until releaseResources()
is invoked.
This DatabaseMetaData
object is not to be used for
runtime query support, although DDL (such as IMPORT FOREIGN SCHEMA) may
use it.
NOTE: if connection pooling is disabled
, the DatabaseMetaData
object returned by this method will be re-used even after a call to
releaseResources()
.
SQLException
- if there's an error obtaining a connection or
metadatapublic void releaseResources()
FarragoMedDataServer
releaseResources
in interface FarragoMedDataServer
releaseResources
in class MedAbstractDataServer
private void closeConnection()
protected static void removeNonDriverProps(Properties props)
public FarragoMedNameDirectory getNameDirectory() throws SQLException
FarragoMedDataServer
getNameDirectory
in interface FarragoMedDataServer
getNameDirectory
in class MedAbstractDataServer
SQLException
- if directory access is unsuccessful (but not if
directory access is unsupported)protected MedJdbcNameDirectory getSchemaNameDirectory()
public FarragoMedColumnSet newColumnSet(String[] localName, Properties tableProps, FarragoTypeFactory typeFactory, RelDataType rowType, Map<String,Properties> columnPropMap) throws SQLException
FarragoMedDataServer
localName
- the qualified name to assign to the column set within
Farrago; this should NOT be used for finding the actual data, since it
can be set arbitrarily by the caller; instead, it should be used to
implement the RelOptTable.getQualifiedName() method, and can be useful
for correlation during debuggingtableProps
- properties to use for data location and accesstypeFactory
- FarragoTypeFactory to use for defining typesrowType
- type to impose on the rows of this column set (including
column names and types), or null to infer row type; if this is non-null,
it must be saved for use by the getRowType() returned from
FarragoMedColumnSetcolumnPropMap
- map from column name to column-specific Properties;
this is optional and may only be specified when rowType is also specified
(the field names in rowType are used as the keys for columnPropMap)
SQLException
- if data access is unsuccessfulpublic Object getRuntimeSupport(Object param) throws SQLException
FarragoMedDataServer
getRuntimeSupport
in interface FarragoMedDataServer
getRuntimeSupport
in class MedAbstractDataServer
param
- parameter supplied at runtime
SQLException
public void registerRelMetadataProviders(ChainedRelMetadataProvider chain)
FarragoMedDataServer
RelMetadataProvider
s in the chain which will be used to answer
relational expression metadata queries during optimization. Wrappers
which define their own relational expressions will generally need to
supply corresponding metadata providers.
registerRelMetadataProviders
in interface FarragoMedDataServer
registerRelMetadataProviders
in class MedAbstractDataServer
chain
- receives wrappers's custom providers, if anypublic void registerRules(RelOptPlanner planner)
FarragoMedDataServer
registerRules
in interface FarragoMedDataServer
registerRules
in class MedAbstractDataServer
planner
- the planner in which the rules should be registeredpublic void closeAllocation()
ClosableAllocation
closeAllocation
in interface ClosableAllocation
closeAllocation
in class MedAbstractDataServer
private void parseMapping(DatabaseMetaData databaseMetaData, String mapping, boolean isTableMapping, boolean isTablePrefixMapping) throws SQLException
SQLException
private void createSchemaMaps(DatabaseMetaData databaseMetaData, String key, String value) throws SQLException
SQLException
private void createTableMaps(String srcSchema, String srcTable, String targetSchema, String targetTable) throws SQLException
SQLException
private void createTablePrefixMaps(String srcSchema, String srcTablePrefix, String targetSchema, String targetTablePrefix) throws SQLException
SQLException
private boolean isQuoteChar(String mapping, int index)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |