public class JdbcDataContext extends AbstractDataContext implements UpdateableDataContext
Modifier and Type | Field and Description |
---|---|
static ColumnType |
COLUMN_TYPE_BLOB_AS_BYTES |
static ColumnType |
COLUMN_TYPE_CLOB_AS_STRING |
static String |
DATABASE_PRODUCT_DB2 |
static String |
DATABASE_PRODUCT_DB2_PREFIX |
static String |
DATABASE_PRODUCT_H2 |
static String |
DATABASE_PRODUCT_HIVE |
static String |
DATABASE_PRODUCT_HSQLDB |
static String |
DATABASE_PRODUCT_IMPALA |
static String |
DATABASE_PRODUCT_MYSQL |
static String |
DATABASE_PRODUCT_ORACLE |
static String |
DATABASE_PRODUCT_POSTGRESQL |
static String |
DATABASE_PRODUCT_SQLITE |
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 and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
void |
close(Connection connection)
Quietly closes the connection
|
CompiledQuery |
compileQuery(Query query)
Compiles a query, preparing it for reuse.
|
DataSet |
executeQuery(CompiledQuery compiledQuery,
Object... values)
Executes a compiled query with given values as parameters.
|
protected DataSet |
executeQuery(Connection connection,
Query query,
boolean closeConnectionOnCloseDataSet) |
DataSet |
executeQuery(Query query)
Executes a query against the DataContext.
|
UpdateSummary |
executeUpdate(UpdateScript update)
Submits an
UpdateScript for execution on the DataContext . |
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 |
getDatabaseProductName() |
String |
getDatabaseVersion() |
String |
getDefaultSchemaName()
Gets the name of the default schema.
|
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)
Gets a specific schema from the non-abstract implementation.
|
protected List<String> |
getSchemaNamesInternal()
Gets schema names from the non-abstract implementation.
|
TableType[] |
getTableTypes() |
protected boolean |
isDefaultAutoCommit() |
protected boolean |
isQualifiedPathDelim(char c) |
protected boolean |
isSingleConnection() |
JdbcDataContext |
setQueryRewriter(IQueryRewriter queryRewriter) |
executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, onSchemaCacheRefreshed, parseQuery, query, refreshSchemas
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, parseQuery, query, refreshSchemas
public static final String SYSTEM_PROPERTY_BATCH_UPDATES
public static final String SYSTEM_PROPERTY_CONVERT_LOBS
public static final String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MAX_SIZE
public static final String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS
public static final String SYSTEM_PROPERTY_COMPILED_QUERY_POOL_TIME_BETWEEN_EVICTION_RUNS_MILLIS
public static final String DATABASE_PRODUCT_POSTGRESQL
public static final String DATABASE_PRODUCT_MYSQL
public static final String DATABASE_PRODUCT_HSQLDB
public static final String DATABASE_PRODUCT_H2
public static final String DATABASE_PRODUCT_SQLSERVER
public static final String DATABASE_PRODUCT_DB2
public static final String DATABASE_PRODUCT_DB2_PREFIX
public static final String DATABASE_PRODUCT_ORACLE
public static final String DATABASE_PRODUCT_HIVE
public static final String DATABASE_PRODUCT_SQLITE
public static final String DATABASE_PRODUCT_IMPALA
public static final ColumnType COLUMN_TYPE_CLOB_AS_STRING
public static final ColumnType COLUMN_TYPE_BLOB_AS_BYTES
public JdbcDataContext(DataSource dataSource, TableType[] tableTypes, String catalogName)
dataSource
- the datasource object to use for making connectionstableTypes
- the types of tables to includecatalogName
- a catalog name to use, can be nullpublic JdbcDataContext(Connection connection, TableType[] tableTypes, String catalogName)
Connection
, some table types and an optional catalogNameconnection
- the database connectiontableTypes
- the types of tables to includecatalogName
- a catalog name to use, can be nullpublic JdbcDataContext(Connection connection)
Connection
connection
- the database connectionpublic JdbcDataContext(DataSource dataSource)
DataSource
dataSource
- the data sourcepublic CompiledQuery compileQuery(Query query)
DataContext
QueryParameter
s as operands in the
WHERE clause, making it possible to reuse the same query with different
parameter values.compileQuery
in interface DataContext
compileQuery
in class AbstractDataContext
query
- the query object to execute, possibly holding one or more
QueryParameter
s.CompiledQuery
after preparing the queryCompiledQuery
,
QueryParameter
public DataSet executeQuery(CompiledQuery compiledQuery, Object... values)
DataContext
executeQuery
in interface DataContext
executeQuery
in class AbstractDataContext
compiledQuery
- the compiledQuery object to executevalues
- the values for parameters in the CompiledQuery
.DataSet
produced from executing the query.public DataSet executeQuery(Query query) throws MetaModelException
DataContext
executeQuery
in interface DataContext
query
- the query object to executeDataSet
produced from executing the queryMetaModelException
- if the specified query does not make sense or cannot be
executed because of restraints on the type of datastore.protected DataSet executeQuery(Connection connection, Query query, boolean closeConnectionOnCloseDataSet)
public void close(Connection connection)
connection
- The connection to close (if it makes sense, @see closeIfNecessary)public String[] getCatalogNames()
public Object getDelegate()
public Connection getConnection()
close(Connection)
method to close the connection (and any ResultSet or Statements
involved).public String getDefaultSchemaName()
AbstractDataContext
getDefaultSchemaName
in class AbstractDataContext
public JdbcDataContext setQueryRewriter(IQueryRewriter queryRewriter)
public IQueryRewriter getQueryRewriter()
public String getIdentifierQuoteString()
protected List<String> getSchemaNamesInternal()
AbstractDataContext
AbstractDataContext.refreshSchemas()
method is called.getSchemaNamesInternal
in class AbstractDataContext
protected Schema getSchemaByNameInternal(String name)
AbstractDataContext
AbstractDataContext.refreshSchemas()
method is called.getSchemaByNameInternal
in class AbstractDataContext
name
- the name of the schema to getpublic org.apache.metamodel.jdbc.FetchSizeCalculator getFetchSizeCalculator()
public UpdateSummary executeUpdate(UpdateScript update) throws RolledBackUpdateException
UpdateScript
for execution on the DataContext
.
Since implementations of the DataContext
vary quite a lot, there
is no golden rule as to how an update script will be executed. But the
implementors should strive towards handling an UpdateScript
as a
single transactional change to the data store.executeUpdate
in interface UpdateableDataContext
update
- the update script to executeRolledBackUpdateException
- when a potentially retryable SQLException
was thrown during the
execution of the update script.protected boolean isSingleConnection()
protected boolean isDefaultAutoCommit()
protected boolean isQualifiedPathDelim(char c)
isQualifiedPathDelim
in class AbstractDataContext
public TableType[] getTableTypes()
public String getCatalogName()
public String getDatabaseProductName()
public String getDatabaseVersion()
Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.