public class JdbcMeta extends Object implements ProtobufMeta
Meta
upon an existing JDBC data source.Modifier and Type | Class and Description |
---|---|
static class |
JdbcMeta.ConnectionCacheSettings
Configurable connection cache settings.
|
static class |
JdbcMeta.StatementCacheSettings
Configurable statement cache settings.
|
Meta.ConnectionHandle, Meta.ConnectionProperties, Meta.CursorFactory, Meta.DatabaseProperty, Meta.ExecuteBatchResult, Meta.ExecuteResult, Meta.Factory, Meta.Frame, Meta.MetaResultSet, Meta.Pat, Meta.PrepareCallback, Meta.Signature, Meta.StatementHandle, Meta.StatementType, Meta.Style
Modifier and Type | Field and Description |
---|---|
static int |
UNLIMITED_COUNT
Special value for
Statement#getLargeMaxRows() that means fetch
an unlimited number of rows in a single batch. |
Constructor and Description |
---|
JdbcMeta(String url)
Creates a JdbcMeta.
|
JdbcMeta(String url,
Properties info) |
JdbcMeta(String url,
Properties info,
MetricsSystem metrics)
Creates a JdbcMeta.
|
JdbcMeta(String url,
String user,
String password)
Creates a JdbcMeta.
|
public static final int UNLIMITED_COUNT
Statement#getLargeMaxRows()
that means fetch
an unlimited number of rows in a single batch.
Any other negative value will return an unlimited number of rows but will do it in the default batch size, namely 100.
public JdbcMeta(String url) throws SQLException
url
- a database url of the form
jdbc:subprotocol:subname
SQLException
public JdbcMeta(String url, String user, String password) throws SQLException
url
- a database url of the form
jdbc:subprotocol:subname
user
- the database user on whose behalf the connection is being
madepassword
- the user's passwordSQLException
public JdbcMeta(String url, Properties info) throws SQLException
SQLException
public JdbcMeta(String url, Properties info, MetricsSystem metrics) throws SQLException
url
- a database url of the form
jdbc:subprotocol:subname
info
- a list of arbitrary string tag/value pairs as
connection arguments; normally at least a "user" and
"password" property should be includedSQLException
protected AtomicInteger getStatementIdGenerator()
protected com.google.common.cache.Cache<String,Connection> getConnectionCache()
protected com.google.common.cache.Cache<Integer,StatementInfo> getStatementCache()
protected static List<ColumnMetaData> columns(ResultSetMetaData metaData) throws SQLException
SQLException
protected static List<AvaticaParameter> parameters(ParameterMetaData metaData) throws SQLException
SQLException
protected static Meta.Signature signature(ResultSetMetaData metaData, ParameterMetaData parameterMetaData, String sql, Meta.StatementType statementType) throws SQLException
SQLException
protected static Meta.Signature signature(ResultSetMetaData metaData) throws SQLException
SQLException
public Map<Meta.DatabaseProperty,Object> getDatabaseProperties(Meta.ConnectionHandle ch)
Meta
The provider can omit properties whose value is the same as the default.
getDatabaseProperties
in interface Meta
public Meta.MetaResultSet getTables(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat tableNamePattern, List<String> typeList)
Meta
public Meta.MetaResultSet getColumns(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat tableNamePattern, Meta.Pat columnNamePattern)
Meta
getColumns
in interface Meta
public Meta.MetaResultSet getSchemas(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern)
getSchemas
in interface Meta
public Meta.MetaResultSet getCatalogs(Meta.ConnectionHandle ch)
Meta
getCatalogs
in interface Meta
public Meta.MetaResultSet getTableTypes(Meta.ConnectionHandle ch)
Meta
getTableTypes
in interface Meta
public Meta.MetaResultSet getProcedures(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat procedureNamePattern)
Meta
getProcedures
in interface Meta
public Meta.MetaResultSet getProcedureColumns(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat procedureNamePattern, Meta.Pat columnNamePattern)
Meta
getProcedureColumns
in interface Meta
public Meta.MetaResultSet getColumnPrivileges(Meta.ConnectionHandle ch, String catalog, String schema, String table, Meta.Pat columnNamePattern)
Meta
getColumnPrivileges
in interface Meta
public Meta.MetaResultSet getTablePrivileges(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat tableNamePattern)
Meta
getTablePrivileges
in interface Meta
public Meta.MetaResultSet getBestRowIdentifier(Meta.ConnectionHandle ch, String catalog, String schema, String table, int scope, boolean nullable)
Meta
getBestRowIdentifier
in interface Meta
public Meta.MetaResultSet getVersionColumns(Meta.ConnectionHandle ch, String catalog, String schema, String table)
Meta
getVersionColumns
in interface Meta
public Meta.MetaResultSet getPrimaryKeys(Meta.ConnectionHandle ch, String catalog, String schema, String table)
Meta
getPrimaryKeys
in interface Meta
public Meta.MetaResultSet getImportedKeys(Meta.ConnectionHandle ch, String catalog, String schema, String table)
Meta
getImportedKeys
in interface Meta
public Meta.MetaResultSet getExportedKeys(Meta.ConnectionHandle ch, String catalog, String schema, String table)
Meta
getExportedKeys
in interface Meta
public Meta.MetaResultSet getCrossReference(Meta.ConnectionHandle ch, String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable)
Meta
getCrossReference
in interface Meta
public Meta.MetaResultSet getTypeInfo(Meta.ConnectionHandle ch)
Meta
getTypeInfo
in interface Meta
public Meta.MetaResultSet getIndexInfo(Meta.ConnectionHandle ch, String catalog, String schema, String table, boolean unique, boolean approximate)
Meta
getIndexInfo
in interface Meta
public Meta.MetaResultSet getUDTs(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat typeNamePattern, int[] types)
Meta
public Meta.MetaResultSet getSuperTypes(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat typeNamePattern)
Meta
getSuperTypes
in interface Meta
public Meta.MetaResultSet getSuperTables(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat tableNamePattern)
Meta
getSuperTables
in interface Meta
public Meta.MetaResultSet getAttributes(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat typeNamePattern, Meta.Pat attributeNamePattern)
Meta
getAttributes
in interface Meta
public Meta.MetaResultSet getClientInfoProperties(Meta.ConnectionHandle ch)
Meta
getClientInfoProperties
in interface Meta
public Meta.MetaResultSet getFunctions(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat functionNamePattern)
Meta
getFunctions
in interface Meta
public Meta.MetaResultSet getFunctionColumns(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat functionNamePattern, Meta.Pat columnNamePattern)
Meta
getFunctionColumns
in interface Meta
public Meta.MetaResultSet getPseudoColumns(Meta.ConnectionHandle ch, String catalog, Meta.Pat schemaPattern, Meta.Pat tableNamePattern, Meta.Pat columnNamePattern)
Meta
getPseudoColumns
in interface Meta
public Iterable<Object> createIterable(Meta.StatementHandle handle, QueryState state, Meta.Signature signature, List<TypedValue> parameterValues, Meta.Frame firstFrame)
Meta
The default implementation just returns iterable
, which it
requires to be not null; derived classes may instead choose to execute the
relational expression in signature
.
createIterable
in interface Meta
protected Connection getConnection(String id) throws SQLException
SQLException
public Meta.StatementHandle createStatement(Meta.ConnectionHandle ch)
Meta
createStatement
in interface Meta
ch
- Connection handlepublic void closeStatement(Meta.StatementHandle h)
Meta
If the statement handle is not known, or is already closed, does nothing.
closeStatement
in interface Meta
h
- Statement handlepublic void openConnection(Meta.ConnectionHandle ch, Map<String,String> info)
Meta
Meta.ConnectionHandle
. The Map info
argument is
analogous to the Properties
typically passed to a "normal" JDBC Driver. Avatica
specific properties should not be included -- only properties for the underlying driver.openConnection
in interface Meta
ch
- A ConnectionHandle encapsulates information about the connection to be opened
as provided by the client.info
- A Map corresponding to the Properties typically passed to a JDBC Driver.protected Connection createConnection(String url, Properties info) throws SQLException
SQLException
public void closeConnection(Meta.ConnectionHandle ch)
Meta
closeConnection
in interface Meta
protected void apply(Connection conn, Meta.ConnectionProperties connProps) throws SQLException
SQLException
public Meta.ConnectionProperties connectionSync(Meta.ConnectionHandle ch, Meta.ConnectionProperties connProps)
Meta
Note: this interface is considered "experimental" and may undergo further changes as this
functionality is extended to other aspects of state management for
Connection
, Statement
, and ResultSet
.
connectionSync
in interface Meta
public Meta.StatementHandle prepare(Meta.ConnectionHandle ch, String sql, long maxRowCount)
Meta
public Meta.ExecuteResult prepareAndExecute(Meta.StatementHandle h, String sql, long maxRowCount, Meta.PrepareCallback callback) throws NoSuchStatementException
Meta
prepareAndExecute
in interface Meta
h
- Statement handlesql
- SQL querymaxRowCount
- Negative for no limit (different meaning than JDBC)callback
- Callback to lock, clear and assign cursorNoSuchStatementException
public Meta.ExecuteResult prepareAndExecute(Meta.StatementHandle h, String sql, long maxRowCount, int maxRowsInFirstFrame, Meta.PrepareCallback callback) throws NoSuchStatementException
Meta
prepareAndExecute
in interface Meta
h
- Statement handlesql
- SQL querymaxRowCount
- Maximum number of rows for the entire query. Negative for no limit
(different meaning than JDBC).maxRowsInFirstFrame
- Maximum number of rows for the first frame. This value should
always be less than or equal to maxRowCount
as the number of results are guaranteed
to be restricted by maxRowCount
and the underlying database.callback
- Callback to lock, clear and assign cursorNoSuchStatementException
public boolean syncResults(Meta.StatementHandle sh, QueryState state, long offset) throws NoSuchStatementException
Meta
ResultSet
on a Statement. Not a JDBC method.syncResults
in interface Meta
NoSuchStatementException
public Meta.Frame fetch(Meta.StatementHandle h, long offset, int fetchMaxRowCount) throws NoSuchStatementException, MissingResultsException
Meta
The frame describes whether there may be another frame. If there is not another frame, the current iteration is done when we have finished the rows in the this frame.
The default implementation always returns null.
fetch
in interface Meta
h
- Statement handleoffset
- Zero-based offset of first row in the requested framefetchMaxRowCount
- Maximum number of rows to return; negative means
no limitNoSuchStatementException
MissingResultsException
public Meta.ExecuteResult execute(Meta.StatementHandle h, List<TypedValue> parameterValues, long maxRowCount) throws NoSuchStatementException
Meta
execute
in interface Meta
h
- Statement handleparameterValues
- A list of parameter values; may be empty, not nullmaxRowCount
- Maximum number of rows to return; negative means
no limitNoSuchStatementException
public Meta.ExecuteResult execute(Meta.StatementHandle h, List<TypedValue> parameterValues, int maxRowsInFirstFrame) throws NoSuchStatementException
Meta
execute
in interface Meta
h
- Statement handleparameterValues
- A list of parameter values; may be empty, not nullmaxRowsInFirstFrame
- Maximum number of rows to return in the Frame.NoSuchStatementException
public void commit(Meta.ConnectionHandle ch)
Meta
Connection.commit()
.public void rollback(Meta.ConnectionHandle ch)
Meta
Connection.rollback()
;public Meta.ExecuteBatchResult prepareAndExecuteBatch(Meta.StatementHandle h, List<String> sqlCommands) throws NoSuchStatementException
Meta
prepareAndExecuteBatch
in interface Meta
h
- Statement handlesqlCommands
- SQL commands to runNoSuchStatementException
public Meta.ExecuteBatchResult executeBatch(Meta.StatementHandle h, List<List<TypedValue>> updateBatches) throws NoSuchStatementException
Meta
executeBatch
in interface Meta
h
- Statement handleupdateBatches
- A collection of list of typed values, one list per batchNoSuchStatementException
public Meta.ExecuteBatchResult executeBatchProtobuf(Meta.StatementHandle h, List<org.apache.calcite.avatica.proto.Requests.UpdateBatch> updateBatches) throws NoSuchStatementException
ProtobufMeta
executeBatchProtobuf
in interface ProtobufMeta
h
- Statement handleupdateBatches
- A collection of list of typed values, one list per batchNoSuchStatementException
Copyright © 2012-2025 Apache Software Foundation. All Rights Reserved.