Package com.firebolt.jdbc.connection
Class FireboltConnection
java.lang.Object
com.firebolt.jdbc.JdbcBase
com.firebolt.jdbc.connection.FireboltConnection
- All Implemented Interfaces:
CacheListener
,GenericWrapper
,AutoCloseable
,Connection
,Wrapper
,EventListener
- Direct Known Subclasses:
FireboltConnectionServiceSecret
,FireboltConnectionUserPassword
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected final FireboltProperties
final ParserVersion
protected FireboltProperties
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
FireboltConnection
(@NonNull String url, Properties connectionSettings, FireboltAuthenticationService fireboltAuthenticationService, FireboltStatementService fireboltStatementService, String protocolVersion, ParserVersion parserVersion) protected
FireboltConnection
(@NonNull String url, Properties connectionSettings, String protocolVersion, ParserVersion parserVersion) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addProperty
(@NonNull String key, String value) By default, when adding a property it is validating the connectionvoid
addProperty
(@NonNull String key, String value, boolean validateConnection) void
addProperty
(Map.Entry<String, String> property) void
addProperty
(Map.Entry<String, String> property, boolean validateConnection) protected abstract void
boolean
cancelAsyncQuery
(String asyncQueryToken) void
cleanup()
void
close()
void
commit()
protected void
connect()
createArrayOf
(String typeName, Object[] elements) protected abstract FireboltAuthenticationClient
createFireboltAuthenticationClient
(okhttp3.OkHttpClient httpClient) createStatement
(int resultSetType, int resultSetConcurrency) createStatement
(int resultSetType, int resultSetConcurrency, int resultSetHoldability) createStruct
(String typeName, Object[] attributes) protected FireboltProperties
extractFireboltProperties
(String jdbcUri, Properties connectionProperties) getAccessToken
(FireboltProperties fireboltProperties) boolean
getClientInfo
(String name) int
A connection should implement this method if it needs to set additional details on the user agent header for the calls sent to Firebolt backendint
protected okhttp3.OkHttpClient
getHttpClient
(FireboltProperties fireboltProperties) abstract int
Returns the version of the firebolt backend the connection is established toint
int
boolean
isAsyncQueryRunning
(String asyncQueryToken) boolean
isAsyncQuerySuccessful
(String asyncQueryToken) boolean
isClosed()
protected abstract boolean
If the connection information can be cached for subsequent reuse, then the specific connection should provide implementationboolean
boolean
isValid
(int timeout) prepareCall
(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) void
register
(CacheListener listener) void
releaseSavepoint
(Savepoint savepoint) void
removeClosedStatement
(FireboltStatement fireboltStatement) void
void
reset()
Server side lets us know when the connection needs to be reset.void
rollback()
void
void
setAutoCommit
(boolean autoCommit) void
setCatalog
(String catalog) void
setClientInfo
(String name, String value) void
setClientInfo
(Properties properties) void
setEndpoint
(String endpoint) void
setHoldability
(int holdability) void
setNetworkTimeout
(Executor executor, int milliseconds) void
setReadOnly
(boolean readOnly) setSavepoint
(String name) void
void
setTransactionIsolation
(int level) void
setTypeMap
(Map<String, Class<?>> map) protected abstract void
Validates that the required parameters are present for the connectionMethods inherited from class com.firebolt.jdbc.JdbcBase
addWarning, clearWarnings, getWarnings
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.Connection
beginRequest, clearWarnings, endRequest, getWarnings, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
Methods inherited from interface com.firebolt.jdbc.GenericWrapper
isWrapperFor, unwrap
-
Field Details
-
httpConnectionUrl
-
sessionProperties
-
loginProperties
-
parserVersion
-
-
Constructor Details
-
FireboltConnection
protected FireboltConnection(@NonNull @NonNull String url, Properties connectionSettings, FireboltAuthenticationService fireboltAuthenticationService, FireboltStatementService fireboltStatementService, String protocolVersion, ParserVersion parserVersion) -
FireboltConnection
protected FireboltConnection(@NonNull @NonNull String url, Properties connectionSettings, String protocolVersion, ParserVersion parserVersion) throws SQLException - Throws:
SQLException
-
-
Method Details
-
createFireboltAuthenticationClient
protected abstract FireboltAuthenticationClient createFireboltAuthenticationClient(okhttp3.OkHttpClient httpClient) -
getHttpClient
protected okhttp3.OkHttpClient getHttpClient(FireboltProperties fireboltProperties) throws SQLException - Throws:
SQLException
-
connect
- Throws:
SQLException
-
getInfraVersion
public abstract int getInfraVersion()Returns the version of the firebolt backend the connection is established to -
authenticate
- Throws:
SQLException
-
validateConnectionParameters
Validates that the required parameters are present for the connection- Throws:
SQLException
-
isConnectionCachingEnabled
protected abstract boolean isConnectionCachingEnabled()If the connection information can be cached for subsequent reuse, then the specific connection should provide implementation- Returns:
- - true if the connection supports caching. False otherwise
-
getConnectionUserAgentHeader
A connection should implement this method if it needs to set additional details on the user agent header for the calls sent to Firebolt backend- Returns:
-
removeExpiredTokens
- Throws:
SQLException
-
getAccessToken
- Throws:
SQLException
-
getAccessToken
protected Optional<String> getAccessToken(FireboltProperties fireboltProperties) throws SQLException - Throws:
SQLException
-
getSessionProperties
-
createStatement
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
getAutoCommit
- Specified by:
getAutoCommit
in interfaceConnection
- Throws:
SQLException
-
setAutoCommit
- Specified by:
setAutoCommit
in interfaceConnection
-
isClosed
public boolean isClosed()- Specified by:
isClosed
in interfaceConnection
-
getMetaData
- Specified by:
getMetaData
in interfaceConnection
- Throws:
SQLException
-
getCatalog
- Specified by:
getCatalog
in interfaceConnection
- Throws:
SQLException
-
setCatalog
- Specified by:
setCatalog
in interfaceConnection
-
getEngine
-
getTransactionIsolation
- Specified by:
getTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
createStatement
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
getSchema
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
setSchema
- Specified by:
setSchema
in interfaceConnection
-
abort
- Specified by:
abort
in interfaceConnection
- Throws:
SQLException
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
-
extractFireboltProperties
protected FireboltProperties extractFireboltProperties(String jdbcUri, Properties connectionProperties) -
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareCall
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
isValid
- Specified by:
isValid
in interfaceConnection
- Throws:
SQLException
-
removeClosedStatement
-
addProperty
By default, when adding a property it is validating the connection- Throws:
SQLException
-
addProperty
public void addProperty(@NonNull @NonNull String key, String value, boolean validateConnection) throws SQLException - Throws:
SQLException
-
addProperty
- Throws:
SQLException
-
addProperty
public void addProperty(Map.Entry<String, String> property, boolean validateConnection) throws SQLException- Throws:
SQLException
-
reset
Server side lets us know when the connection needs to be reset. so no need to validate the connection.- Throws:
SQLException
-
setEndpoint
-
getEndpoint
-
commit
- Specified by:
commit
in interfaceConnection
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
setNetworkTimeout
- Specified by:
setNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout()- Specified by:
getNetworkTimeout
in interfaceConnection
-
getConnectionTimeout
public int getConnectionTimeout() -
nativeSQL
- Specified by:
nativeSQL
in interfaceConnection
- Throws:
SQLException
-
isReadOnly
- Specified by:
isReadOnly
in interfaceConnection
- Throws:
SQLException
-
setReadOnly
- Specified by:
setReadOnly
in interfaceConnection
-
prepareCall
@NotImplemented public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
getTypeMap
- Specified by:
getTypeMap
in interfaceConnection
-
setTypeMap
- Specified by:
setTypeMap
in interfaceConnection
- Throws:
SQLException
-
getHoldability
- Specified by:
getHoldability
in interfaceConnection
- Throws:
SQLException
-
setHoldability
- Specified by:
setHoldability
in interfaceConnection
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
releaseSavepoint
- Specified by:
releaseSavepoint
in interfaceConnection
- Throws:
SQLException
-
prepareCall
@NotImplemented public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
createClob
- Specified by:
createClob
in interfaceConnection
-
createBlob
- Specified by:
createBlob
in interfaceConnection
-
createNClob
- Specified by:
createNClob
in interfaceConnection
-
createSQLXML
- Specified by:
createSQLXML
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
createArrayOf
- Specified by:
createArrayOf
in interfaceConnection
- Throws:
SQLException
-
createStruct
@NotImplemented public Struct createStruct(String typeName, Object[] attributes) throws SQLException - Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
getProtocolVersion
-
register
-
cleanup
public void cleanup()- Specified by:
cleanup
in interfaceCacheListener
-
isAsyncQueryRunning
- Throws:
SQLException
-
isAsyncQuerySuccessful
- Throws:
SQLException
-
cancelAsyncQuery
- Throws:
SQLException
-