Class DatabricksConnection
java.lang.Object
com.databricks.jdbc.api.impl.DatabricksConnection
- All Implemented Interfaces:
IDatabricksConnection,IDatabricksConnectionInternal,AutoCloseable,Connection,Wrapper
public class DatabricksConnection
extends Object
implements IDatabricksConnection, IDatabricksConnectionInternal
Implementation for Databricks specific connection.
-
Field Summary
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Constructor Summary
ConstructorsConstructorDescriptionDatabricksConnection(IDatabricksConnectionContext connectionContext) Creates an instance of Databricks connection for given connection context.DatabricksConnection(IDatabricksConnectionContext connectionContext, IDatabricksClient testDatabricksClient) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidclose()voidcloseStatement(IDatabricksStatement statement) Closes a statement from the connection's active set.voidcommit()createArrayOf(String typeName, Object[] elements) createStatement(int resultSetType, int resultSetConcurrency) createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) createStruct(String typeName, Object[] attributes) voidbooleanRetrieves all client and session properties as a Properties object.getClientInfo(String name) Retrieves the value of the specified client info property. case-insensitiveReturns the corresponding sql connection objectReturns the connection context associated with the connection.Retrieves the unique identifier for this connection.intintReturns the underlying session for the connection.getStatement(String statementId) Retrieves a statement handle for a given statement ID.intbooleanisClosed()booleanbooleanisValid(int timeout) booleanisWrapperFor(Class<?> iface) voidopen()Opens the connection and initiates the underlying sessionprepareCall(String sql) prepareCall(String sql, int resultSetType, int resultSetConcurrency) prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement(String sql) prepareStatement(String sql, int autoGeneratedKeys) prepareStatement(String sql, int[] columnIndexes) prepareStatement(String sql, int resultSetType, int resultSetConcurrency) prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement(String sql, String[] columnNames) voidreleaseSavepoint(Savepoint savepoint) voidrollback()voidvoidsetAutoCommit(boolean autoCommit) voidsetCatalog(String catalog) voidsetClientInfo(String name, String value) Sets a client info property/session configvoidsetClientInfo(Properties properties) Sets multiple client info properties from the provided Properties object.voidsetHoldability(int holdability) voidsetNetworkTimeout(Executor executor, int milliseconds) voidsetReadOnly(boolean readOnly) setSavepoint(String name) voidvoidsetShardingKey(ShardingKey shardingKey) voidsetShardingKey(ShardingKey shardingKey, ShardingKey superShardingKey) booleansetShardingKeyIfValid(ShardingKey shardingKey, int timeout) booleansetShardingKeyIfValid(ShardingKey shardingKey, ShardingKey superShardingKey, int timeout) voidsetTransactionIsolation(int level) voidsetTypeMap(Map<String, Class<?>> map) <T> T
-
Constructor Details
-
DatabricksConnection
public DatabricksConnection(IDatabricksConnectionContext connectionContext) throws DatabricksSQLException Creates an instance of Databricks connection for given connection context.- Parameters:
connectionContext- underlying connection context- Throws:
DatabricksSQLException
-
DatabricksConnection
public DatabricksConnection(IDatabricksConnectionContext connectionContext, IDatabricksClient testDatabricksClient) throws DatabricksSQLException - Throws:
DatabricksSQLException
-
-
Method Details
-
open
Description copied from interface:IDatabricksConnectionInternalOpens the connection and initiates the underlying session- Specified by:
openin interfaceIDatabricksConnectionInternal- Throws:
DatabricksSQLException
-
getStatement
Description copied from interface:IDatabricksConnectionRetrieves a statement handle for a given statement ID.- Specified by:
getStatementin interfaceIDatabricksConnection- Parameters:
statementId- The unique identifier of the statement to retrieve- Returns:
- A
Statementobject representing the statement - Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
-
getConnectionId
Description copied from interface:IDatabricksConnectionRetrieves the unique identifier for this connection.- Specified by:
getConnectionIdin interfaceIDatabricksConnection- Returns:
- A string representing the unique connection ID
- Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
-
getSession
Description copied from interface:IDatabricksConnectionInternalReturns the underlying session for the connection.- Specified by:
getSessionin interfaceIDatabricksConnectionInternal
-
createStatement
- Specified by:
createStatementin interfaceConnection
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection
-
prepareCall
- Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
nativeSQL
- Specified by:
nativeSQLin interfaceConnection- Throws:
SQLException
-
setAutoCommit
- Specified by:
setAutoCommitin interfaceConnection- Throws:
SQLException
-
getAutoCommit
- Specified by:
getAutoCommitin interfaceConnection- Throws:
SQLException
-
commit
- Specified by:
commitin interfaceConnection- Throws:
SQLException
-
rollback
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
DatabricksSQLException
-
isClosed
- Specified by:
isClosedin interfaceConnection- Throws:
SQLException
-
getMetaData
- Specified by:
getMetaDatain interfaceConnection- Throws:
SQLException
-
setReadOnly
- Specified by:
setReadOnlyin interfaceConnection- Throws:
SQLException
-
isReadOnly
- Specified by:
isReadOnlyin interfaceConnection- Throws:
SQLException
-
setCatalog
- Specified by:
setCatalogin interfaceConnection- Throws:
SQLException
-
getCatalog
- Specified by:
getCatalogin interfaceConnection- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolationin interfaceConnection- Throws:
SQLException
-
getTransactionIsolation
- Specified by:
getTransactionIsolationin interfaceConnection- Throws:
SQLException
-
getWarnings
- Specified by:
getWarningsin interfaceConnection- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarningsin interfaceConnection- Throws:
SQLException
-
createStatement
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
getTypeMap
- Specified by:
getTypeMapin interfaceConnection
-
setTypeMap
- Specified by:
setTypeMapin interfaceConnection- Throws:
SQLException
-
setHoldability
- Specified by:
setHoldabilityin interfaceConnection- Throws:
SQLException
-
getHoldability
- Specified by:
getHoldabilityin interfaceConnection- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
rollback
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
releaseSavepoint
- Specified by:
releaseSavepointin interfaceConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
createClob
- Specified by:
createClobin interfaceConnection- Throws:
SQLException
-
createBlob
- Specified by:
createBlobin interfaceConnection- Throws:
SQLException
-
createNClob
- Specified by:
createNClobin interfaceConnection- Throws:
SQLException
-
createSQLXML
- Specified by:
createSQLXMLin interfaceConnection- Throws:
SQLException
-
isValid
- Specified by:
isValidin interfaceConnection- Throws:
SQLException
-
setClientInfo
Sets a client info property/session config- Specified by:
setClientInfoin interfaceConnection- Parameters:
name- The name of the property to setvalue- The value to set- Throws:
SQLClientInfoException- If the property cannot be set due to validation errors or if the property name is not recognized
-
setClientInfo
Sets multiple client info properties from the provided Properties object.- Specified by:
setClientInfoin interfaceConnection- Parameters:
properties- The properties containing client info to set- Throws:
SQLClientInfoException- If any property cannot be set
-
getClientInfo
Retrieves the value of the specified client info property. case-insensitive- Specified by:
getClientInfoin interfaceConnection- Parameters:
name- The name of the client info property to retrieve- Returns:
- The value of the specified client info property, or null if not found
- Throws:
SQLException- If a database access error occurs
-
getClientInfo
Retrieves all client and session properties as a Properties object. Keys are in lower case.The returned Properties object contains default session configurations, user-defined session configurations, and client info properties.
- Specified by:
getClientInfoin interfaceConnection- Returns:
- A Properties object containing all client info properties
- Throws:
SQLException- If a database access error occurs
-
createArrayOf
- Specified by:
createArrayOfin interfaceConnection- Throws:
SQLException
-
createStruct
- Specified by:
createStructin interfaceConnection- Throws:
SQLException
-
setSchema
- Specified by:
setSchemain interfaceConnection- Throws:
SQLException
-
getSchema
- Specified by:
getSchemain interfaceConnection- Throws:
SQLException
-
abort
- Specified by:
abortin interfaceConnection- Throws:
SQLException
-
setNetworkTimeout
- Specified by:
setNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
getNetworkTimeout
- Specified by:
getNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
closeStatement
Description copied from interface:IDatabricksConnectionInternalCloses a statement from the connection's active set.- Specified by:
closeStatementin interfaceIDatabricksConnectionInternal- Parameters:
statement-IDatabricksStatementto be closed
-
beginRequest
public void beginRequest()- Specified by:
beginRequestin interfaceConnection
-
endRequest
public void endRequest()- Specified by:
endRequestin interfaceConnection
-
setShardingKeyIfValid
public boolean setShardingKeyIfValid(ShardingKey shardingKey, ShardingKey superShardingKey, int timeout) throws DatabricksSQLFeatureNotImplementedException - Specified by:
setShardingKeyIfValidin interfaceConnection- Throws:
DatabricksSQLFeatureNotImplementedException
-
setShardingKeyIfValid
public boolean setShardingKeyIfValid(ShardingKey shardingKey, int timeout) throws DatabricksSQLFeatureNotImplementedException - Specified by:
setShardingKeyIfValidin interfaceConnection- Throws:
DatabricksSQLFeatureNotImplementedException
-
setShardingKey
public void setShardingKey(ShardingKey shardingKey, ShardingKey superShardingKey) throws DatabricksSQLFeatureNotImplementedException - Specified by:
setShardingKeyin interfaceConnection- Throws:
DatabricksSQLFeatureNotImplementedException
-
setShardingKey
public void setShardingKey(ShardingKey shardingKey) throws DatabricksSQLFeatureNotImplementedException - Specified by:
setShardingKeyin interfaceConnection- Throws:
DatabricksSQLFeatureNotImplementedException
-
getConnection
Description copied from interface:IDatabricksConnectionInternalReturns the corresponding sql connection object- Specified by:
getConnectionin interfaceIDatabricksConnectionInternal
-
getConnectionContext
Description copied from interface:IDatabricksConnectionInternalReturns the connection context associated with the connection.- Specified by:
getConnectionContextin interfaceIDatabricksConnectionInternal
-