org.apache.metamodel.jdbc
Class JdbcDataContext

java.lang.Object
  extended by org.apache.metamodel.AbstractDataContext
      extended by org.apache.metamodel.jdbc.JdbcDataContext
All Implemented Interfaces:
DataContext, UpdateableDataContext

public class JdbcDataContext
extends AbstractDataContext
implements UpdateableDataContext

DataContextStrategy to use for JDBC-compliant databases


Field Summary
static String DATABASE_PRODUCT_DB2
           
static String DATABASE_PRODUCT_DB2_PREFIX
           
static String DATABASE_PRODUCT_H2
           
static String DATABASE_PRODUCT_HSQLDB
           
static String DATABASE_PRODUCT_MYSQL
           
static String DATABASE_PRODUCT_POSTGRESQL
           
static String DATABASE_PRODUCT_SQLSERVER
           
static String SYSTEM_PROPERTY_BATCH_UPDATES
           
static String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MAX_SIZE
           
static String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS
           
static String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_TIME_BETWEEN_EVICTION_RUNS_MILLIS
           
static String SYSTEM_PROPERTY_CONVERT_LOBS
           
 
Constructor Summary
JdbcDataContext(Connection connection)
          Creates the strategy based on a Connection
JdbcDataContext(Connection connection, TableType[] tableTypes, String catalogName)
          Creates the strategy based on a Connection, some table types and an optional catalogName
JdbcDataContext(DataSource dataSource)
          Creates the strategy based on a DataSource
JdbcDataContext(DataSource dataSource, TableType[] tableTypes, String catalogName)
          Creates the strategy based on a data source, some table types and an optional catalogName
 
Method Summary
 void close(Connection connection, ResultSet rs, Statement st)
          Quietly closes any of the parameterized JDBC objects
 CompiledQuery compileQuery(Query query)
           
 DataSet executeQuery(CompiledQuery compiledQuery, Object... values)
           
 DataSet executeQuery(Query query)
           
 void executeUpdate(UpdateScript update)
           
 String getCatalogName()
           
 String[] getCatalogNames()
          Convenience method to get the available catalogNames using this connection.
 Connection getConnection()
          Gets an appropriate connection object to use - either a dedicated connection or a new connection from the datasource object.
 String getDefaultSchemaName()
           
 Object getDelegate()
          Gets the delegate from the JDBC API (ie.
 org.apache.metamodel.jdbc.FetchSizeCalculator getFetchSizeCalculator()
           
 String getIdentifierQuoteString()
           
 IQueryRewriter getQueryRewriter()
           
protected  Schema getSchemaByNameInternal(String name)
           
protected  String[] getSchemaNamesInternal()
           
 TableType[] getTableTypes()
           
protected  boolean isDefaultAutoCommit()
           
protected  boolean isQualifiedPathDelim(char c)
           
protected  boolean isSingleConnection()
           
 JdbcDataContext setQueryRewriter(IQueryRewriter queryRewriter)
           
 
Methods inherited from class org.apache.metamodel.AbstractDataContext
executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.metamodel.DataContext
executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemas
 

Field Detail

SYSTEM_PROPERTY_BATCH_UPDATES

public static final String SYSTEM_PROPERTY_BATCH_UPDATES
See Also:
Constant Field Values

SYSTEM_PROPERTY_CONVERT_LOBS

public static final String SYSTEM_PROPERTY_CONVERT_LOBS
See Also:
Constant Field Values

SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MAX_SIZE

public static final String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MAX_SIZE
See Also:
Constant Field Values

SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS

public static final String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS
See Also:
Constant Field Values

SYSTEM_PROPERTY_COMPILED_QUERY_POOL_TIME_BETWEEN_EVICTION_RUNS_MILLIS

public static final String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_TIME_BETWEEN_EVICTION_RUNS_MILLIS
See Also:
Constant Field Values

DATABASE_PRODUCT_POSTGRESQL

public static final String DATABASE_PRODUCT_POSTGRESQL
See Also:
Constant Field Values

DATABASE_PRODUCT_MYSQL

public static final String DATABASE_PRODUCT_MYSQL
See Also:
Constant Field Values

DATABASE_PRODUCT_HSQLDB

public static final String DATABASE_PRODUCT_HSQLDB
See Also:
Constant Field Values

DATABASE_PRODUCT_H2

public static final String DATABASE_PRODUCT_H2
See Also:
Constant Field Values

DATABASE_PRODUCT_SQLSERVER

public static final String DATABASE_PRODUCT_SQLSERVER
See Also:
Constant Field Values

DATABASE_PRODUCT_DB2

public static final String DATABASE_PRODUCT_DB2
See Also:
Constant Field Values

DATABASE_PRODUCT_DB2_PREFIX

public static final String DATABASE_PRODUCT_DB2_PREFIX
See Also:
Constant Field Values
Constructor Detail

JdbcDataContext

public JdbcDataContext(DataSource dataSource,
                       TableType[] tableTypes,
                       String catalogName)
Creates the strategy based on a data source, some table types and an optional catalogName

Parameters:
dataSource - the datasource objcet to use for making connections
tableTypes - the types of tables to include
catalogName - a catalog name to use, can be null

JdbcDataContext

public JdbcDataContext(Connection connection,
                       TableType[] tableTypes,
                       String catalogName)
Creates the strategy based on a Connection, some table types and an optional catalogName

Parameters:
connection - the database connection
tableTypes - the types of tables to include
catalogName - a catalog name to use, can be null

JdbcDataContext

public JdbcDataContext(Connection connection)
Creates the strategy based on a Connection

Parameters:
connection - the database connection

JdbcDataContext

public JdbcDataContext(DataSource dataSource)
Creates the strategy based on a DataSource

Parameters:
dataSource - the data source
Method Detail

compileQuery

public CompiledQuery compileQuery(Query query)
Specified by:
compileQuery in interface DataContext
Overrides:
compileQuery in class AbstractDataContext

executeQuery

public DataSet executeQuery(CompiledQuery compiledQuery,
                            Object... values)
Specified by:
executeQuery in interface DataContext
Overrides:
executeQuery in class AbstractDataContext

executeQuery

public DataSet executeQuery(Query query)
                     throws MetaModelException
Specified by:
executeQuery in interface DataContext
Throws:
MetaModelException

close

public void close(Connection connection,
                  ResultSet rs,
                  Statement st)
Quietly closes any of the parameterized JDBC objects

Parameters:
connection -
rs -
st -

getCatalogNames

public String[] getCatalogNames()
Convenience method to get the available catalogNames using this connection.

Returns:
a String-array with the names of the available catalogs.

getDelegate

public Object getDelegate()
Gets the delegate from the JDBC API (ie. Connection or DataSource) that is being used to perform database interactions.

Returns:
either a DataSource or a Connection, depending on the configuration of the DataContext.

getConnection

public Connection getConnection()
Gets an appropriate connection object to use - either a dedicated connection or a new connection from the datasource object. Hint: Use the close(Connection, ResultSet, Statement) method to close the connection (and any ResultSet or Statements involved).


getDefaultSchemaName

public String getDefaultSchemaName()
Specified by:
getDefaultSchemaName in class AbstractDataContext

setQueryRewriter

public JdbcDataContext setQueryRewriter(IQueryRewriter queryRewriter)

getQueryRewriter

public IQueryRewriter getQueryRewriter()

getIdentifierQuoteString

public String getIdentifierQuoteString()

getSchemaNamesInternal

protected String[] getSchemaNamesInternal()
Specified by:
getSchemaNamesInternal in class AbstractDataContext

getSchemaByNameInternal

protected Schema getSchemaByNameInternal(String name)
Specified by:
getSchemaByNameInternal in class AbstractDataContext

getFetchSizeCalculator

public org.apache.metamodel.jdbc.FetchSizeCalculator getFetchSizeCalculator()

executeUpdate

public void executeUpdate(UpdateScript update)
Specified by:
executeUpdate in interface UpdateableDataContext

isSingleConnection

protected boolean isSingleConnection()

isDefaultAutoCommit

protected boolean isDefaultAutoCommit()

isQualifiedPathDelim

protected boolean isQualifiedPathDelim(char c)
Overrides:
isQualifiedPathDelim in class AbstractDataContext

getTableTypes

public TableType[] getTableTypes()

getCatalogName

public String getCatalogName()


Copyright © 2007-2014 The Apache Software Foundation. All Rights Reserved.