Package com.clickhouse.jdbc.internal
Class ClickHouseConnectionImpl
java.lang.Object
com.clickhouse.jdbc.JdbcWrapper
com.clickhouse.jdbc.internal.ClickHouseConnectionImpl
- All Implemented Interfaces:
ClickHouseConnection,AutoCloseable,Connection,Wrapper
-
Field Summary
Fields inherited from interface com.clickhouse.jdbc.ClickHouseConnection
COLUMN_ARRAY, COLUMN_ELEMENT, PROP_APPLICATION_NAME, PROP_CUSTOM_HTTP_HEADERS, PROP_CUSTOM_HTTP_PARAMSFields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanChecks whether custom setting is allowed or not.voidbegin()Starts a new transaction.voidvoidclose()voidcommit()protected JdbcSavepointcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) protected JdbcTransactionprotected voidChecks if the connection is open or not.protected voidensureSupport(String feature, boolean silent) Checks if a feature can be supported or not.protected voidbooleangetClientInfo(String name) Gets configuration tied to this connection.Gets current database.Gets current user.protected StringGets default calendar which can be used to create timestamp.Gets effective time zone.intGets JDBC-specific configuration.Gets cached value ofTimeZone.getDefault().longGets max insert block size.intprotected static ClickHouseRecordgetServerInfo(ClickHouseNode node, ClickHouseRequest<?> request, boolean createDbIfNotExist) Gets server time zone, which is either same as result ofselect timezone(), or the overrided value fromClickHouseConfig.getServerTimeZone().Gets server version.protected List<ClickHouseColumn>getTableColumns(String dbName, String tableName, String columns) Gets current transaction.intgetUri()Gets URI of the connection.booleanisClosed()booleanChecks whether implicit transaction is supported.booleanbooleanChecks whether transaction is supported.booleanisValid(int timeout) booleanisWrapperFor(Class<?> iface) Creates a new query ID.parse(String sql, ClickHouseConfig config, Map<String, Serializable> settings) Parses the given sql.prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) voidreleaseSavepoint(Savepoint savepoint) voidrollback()voidvoidsetAutoCommit(boolean autoCommit) voidsetCatalog(String catalog) voidsetClientInfo(String name, String value) voidsetClientInfo(Properties properties) voidsetCurrentDatabase(String db, boolean check) Sets current database.voidsetHoldability(int holdability) voidsetNetworkTimeout(Executor executor, int milliseconds) voidsetReadOnly(boolean readOnly) setSavepoint(String name) voidvoidsetTransactionIsolation(int level) voidsetTypeMap(Map<String, Class<?>> map) <T> TMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.clickhouse.jdbc.ClickHouseConnection
createArrayOf, createBlob, createClob, createSQLXML, createStatement, createStatement, createStruct, getJdbcTypeMapping, parse, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatementMethods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
Constructor Details
-
ClickHouseConnectionImpl
- Throws:
SQLException
-
ClickHouseConnectionImpl
- Throws:
SQLException
-
ClickHouseConnectionImpl
public ClickHouseConnectionImpl(ClickHouseJdbcUrlParser.ConnectionInfo connInfo) throws SQLException - Throws:
SQLException
-
-
Method Details
-
getServerInfo
protected static ClickHouseRecord getServerInfo(ClickHouseNode node, ClickHouseRequest<?> request, boolean createDbIfNotExist) throws SQLException - Throws:
SQLException
-
createTransaction
- Throws:
SQLException
-
createSavepoint
-
ensureOpen
Checks if the connection is open or not.- Throws:
SQLException- when the connection is closed
-
ensureSupport
Checks if a feature can be supported or not.- Parameters:
feature- non-empty feature namesilent- whether to show warning in log or throw unsupported exception- Throws:
SQLException- when the feature is not supported and silent isfalse
-
ensureTransactionSupport
- Throws:
SQLException
-
getTableColumns
protected List<ClickHouseColumn> getTableColumns(String dbName, String tableName, String columns) throws SQLException - Throws:
SQLException
-
getDatabase
- Throws:
SQLException
-
nativeSQL
- Specified by:
nativeSQLin interfaceConnection- Throws:
SQLException
-
setAutoCommit
- Specified by:
setAutoCommitin interfaceConnection- Throws:
SQLException
-
getAutoCommit
- Specified by:
getAutoCommitin interfaceConnection- Throws:
SQLException
-
begin
Description copied from interface:ClickHouseConnectionStarts a new transaction. It's no-op for a newly started transaction.- Specified by:
beginin interfaceClickHouseConnection- Throws:
SQLException- when current transaction is active state or not able to start new transaction
-
commit
- Specified by:
commitin interfaceConnection- Throws:
SQLException
-
rollback
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
SQLException
-
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
-
getTypeMap
- Specified by:
getTypeMapin interfaceConnection- Throws:
SQLException
-
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 ClickHouseStatement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatementin interfaceClickHouseConnection- 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
-
createNClob
- Specified by:
createNClobin interfaceConnection- Throws:
SQLException
-
isValid
- Specified by:
isValidin interfaceConnection- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
setClientInfo
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
getClientInfo
- Specified by:
getClientInfoin interfaceConnection- Throws:
SQLException
-
getClientInfo
- Specified by:
getClientInfoin 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
-
getConfig
Description copied from interface:ClickHouseConnectionGets configuration tied to this connection.- Specified by:
getConfigin interfaceClickHouseConnection- Returns:
- non-null configuration
-
allowCustomSetting
public boolean allowCustomSetting()Description copied from interface:ClickHouseConnectionChecks whether custom setting is allowed or not.- Specified by:
allowCustomSettingin interfaceClickHouseConnection- Returns:
- true if custom setting is allowed; false otherwise
-
getCurrentDatabase
Description copied from interface:ClickHouseConnectionGets current database.Connection.getSchema()is similar but it will check if connection is closed or not hence may throwSQLException.- Specified by:
getCurrentDatabasein interfaceClickHouseConnection- Returns:
- non-null database name
-
setCurrentDatabase
Description copied from interface:ClickHouseConnectionSets current database.- Specified by:
setCurrentDatabasein interfaceClickHouseConnection- Parameters:
db- non-empty database namecheck- whether to check if the database exists or not- Throws:
SQLException- when failed to change current database
-
getCurrentUser
Description copied from interface:ClickHouseConnectionGets current user.- Specified by:
getCurrentUserin interfaceClickHouseConnection- Returns:
- non-null user name
-
getDefaultCalendar
Description copied from interface:ClickHouseConnectionGets default calendar which can be used to create timestamp.- Specified by:
getDefaultCalendarin interfaceClickHouseConnection- Returns:
- non-null calendar
-
getEffectiveTimeZone
Description copied from interface:ClickHouseConnectionGets effective time zone. WhenClickHouseConfig.isUseServerTimeZone()returnsfalse,ClickHouseConfig.getUseTimeZone()will be used as effective time zone, which will be used for reading and writing timestamp values.- Specified by:
getEffectiveTimeZonein interfaceClickHouseConnection- Returns:
- effective time zone
-
getJvmTimeZone
Description copied from interface:ClickHouseConnectionGets cached value ofTimeZone.getDefault().- Specified by:
getJvmTimeZonein interfaceClickHouseConnection- Returns:
- non-null cached JVM time zone
-
getServerTimeZone
Description copied from interface:ClickHouseConnectionGets server time zone, which is either same as result ofselect timezone(), or the overrided value fromClickHouseConfig.getServerTimeZone().- Specified by:
getServerTimeZonein interfaceClickHouseConnection- Returns:
- non-null server time zone
-
getServerVersion
Description copied from interface:ClickHouseConnectionGets server version.- Specified by:
getServerVersionin interfaceClickHouseConnection- Returns:
- non-null server version
-
getTransaction
Description copied from interface:ClickHouseConnectionGets current transaction.- Specified by:
getTransactionin interfaceClickHouseConnection- Returns:
- current transaction, which could be null
-
getUri
Description copied from interface:ClickHouseConnectionGets URI of the connection.- Specified by:
getUriin interfaceClickHouseConnection- Returns:
- URI of the connection
-
getJdbcConfig
Description copied from interface:ClickHouseConnectionGets JDBC-specific configuration.- Specified by:
getJdbcConfigin interfaceClickHouseConnection- Returns:
- non-null JDBC-specific configuration
-
getMaxInsertBlockSize
public long getMaxInsertBlockSize()Description copied from interface:ClickHouseConnectionGets max insert block size. Pay attention that INSERT into one partition in one table of MergeTree family up to max_insert_block_size rows is transactional.- Specified by:
getMaxInsertBlockSizein interfaceClickHouseConnection- Returns:
- value of max_insert_block_size
-
isTransactionSupported
public boolean isTransactionSupported()Description copied from interface:ClickHouseConnectionChecks whether transaction is supported.- Specified by:
isTransactionSupportedin interfaceClickHouseConnection- Returns:
- true if transaction is supported; false otherwise
-
isImplicitTransactionSupported
public boolean isImplicitTransactionSupported()Description copied from interface:ClickHouseConnectionChecks whether implicit transaction is supported.- Specified by:
isImplicitTransactionSupportedin interfaceClickHouseConnection- Returns:
- true if implicit transaction is supported; false otherwise
-
newQueryId
Description copied from interface:ClickHouseConnectionCreates a new query ID.- Specified by:
newQueryIdin interfaceClickHouseConnection- Returns:
- universal unique query ID
-
parse
public ClickHouseSqlStatement[] parse(String sql, ClickHouseConfig config, Map<String, Serializable> settings) Description copied from interface:ClickHouseConnectionParses the given sql.- Specified by:
parsein interfaceClickHouseConnection- Parameters:
sql- sql to parseconfig- configuration which might be used for parsing, could be nullsettings- server settings- Returns:
- non-null parsed sql statements
-
isWrapperFor
- Specified by:
isWrapperForin interfaceWrapper- Overrides:
isWrapperForin classJdbcWrapper- Throws:
SQLException
-
unwrap
- Specified by:
unwrapin interfaceWrapper- Overrides:
unwrapin classJdbcWrapper- Throws:
SQLException
-