Package com.clickhouse.jdbc
Interface ClickHouseConnection
- All Superinterfaces:
AutoCloseable,Connection,Wrapper
- All Known Implementing Classes:
ClickHouseConnectionImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether custom setting is allowed or not.voidbegin()Starts a new transaction.default ClickHouseArraycreateArrayOf(String typeName, Object[] elements) default ClickHouseBlobdefault ClickHouseClobdefault ClickHouseXmldefault ClickHouseStatementdefault ClickHouseStatementcreateStatement(int resultSetType, int resultSetConcurrency) createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) default ClickHouseStructcreateStruct(String typeName, Object[] attributes) com.clickhouse.client.ClickHouseConfigGets configuration tied to this connection.Gets current database.Gets current user.Gets default calendar which can be used to create timestamp.Gets effective time zone.Gets JDBC-specific configuration.default JdbcTypeMappingGets JDBC type mapping.Gets cached value ofTimeZone.getDefault().longGets max insert block size.Gets server time zone, which is either same as result ofselect timezone(), or the overrided value fromClickHouseConfig.getServerTimeZone().com.clickhouse.data.ClickHouseVersionGets server version.com.clickhouse.client.ClickHouseTransactionGets current transaction.getUri()Gets URI of the connection.booleanChecks whether implicit transaction is supported.booleanChecks whether transaction is supported.Creates a new query ID.default ClickHouseSqlStatement[]Deprecated.parse(String sql, com.clickhouse.client.ClickHouseConfig config, Map<String, Serializable> settings) Parses the given sql.default CallableStatementprepareCall(String sql) default CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency) default CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) default PreparedStatementprepareStatement(String sql) default PreparedStatementprepareStatement(String sql, int autoGeneratedKeys) default PreparedStatementprepareStatement(String sql, int[] columnIndexes) default PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency) default PreparedStatementprepareStatement(String sql, String[] columnNames) voidsetCurrentDatabase(String database, boolean check) Sets current database.Methods inherited from interface java.sql.Connection
abort, beginRequest, clearWarnings, close, commit, createNClob, endRequest, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, isValid, nativeSQL, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid, setTransactionIsolation, setTypeMapMethods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
-
Field Details
-
COLUMN_ELEMENT
- See Also:
-
COLUMN_ARRAY
- See Also:
-
PROP_APPLICATION_NAME
- See Also:
-
PROP_CUSTOM_HTTP_HEADERS
- See Also:
-
PROP_CUSTOM_HTTP_PARAMS
- See Also:
-
-
Method Details
-
createArrayOf
- Specified by:
createArrayOfin interfaceConnection- Throws:
SQLException
-
createBlob
- Specified by:
createBlobin interfaceConnection- Throws:
SQLException
-
createClob
- Specified by:
createClobin interfaceConnection- Throws:
SQLException
-
createStruct
- Specified by:
createStructin interfaceConnection- Throws:
SQLException
-
createSQLXML
- Specified by:
createSQLXMLin interfaceConnection- Throws:
SQLException
-
createStatement
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
createStatement
default ClickHouseStatement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
createStatement
ClickHouseStatement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
prepareCall
- Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
prepareCall
default CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
prepareCall
default 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
-
prepareStatement
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
default PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
begin
Starts a new transaction. It's no-op for a newly started transaction.- Throws:
SQLException- when current transaction is active state or not able to start new transaction
-
getConfig
com.clickhouse.client.ClickHouseConfig getConfig()Gets configuration tied to this connection.- Returns:
- non-null configuration
-
allowCustomSetting
boolean allowCustomSetting()Checks whether custom setting is allowed or not.- Returns:
- true if custom setting is allowed; false otherwise
-
getCurrentDatabase
String getCurrentDatabase()Gets current database.Connection.getSchema()is similar but it will check if connection is closed or not hence may throwSQLException.- Returns:
- non-null database name
-
setCurrentDatabase
Sets current database.- Parameters:
database- non-empty database namecheck- whether to check if the database exists or not- Throws:
SQLException- when failed to change current database
-
getCurrentUser
String getCurrentUser()Gets current user.- Returns:
- non-null user name
-
getDefaultCalendar
Calendar getDefaultCalendar()Gets default calendar which can be used to create timestamp.- Returns:
- non-null calendar
-
getEffectiveTimeZone
Gets 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.- Returns:
- effective time zone
-
getJvmTimeZone
TimeZone getJvmTimeZone()Gets cached value ofTimeZone.getDefault().- Returns:
- non-null cached JVM time zone
-
getServerTimeZone
TimeZone getServerTimeZone()Gets server time zone, which is either same as result ofselect timezone(), or the overrided value fromClickHouseConfig.getServerTimeZone().- Returns:
- non-null server time zone
-
getServerVersion
com.clickhouse.data.ClickHouseVersion getServerVersion()Gets server version.- Returns:
- non-null server version
-
getTransaction
com.clickhouse.client.ClickHouseTransaction getTransaction()Gets current transaction.- Returns:
- current transaction, which could be null
-
getUri
URI getUri()Gets URI of the connection.- Returns:
- URI of the connection
-
getJdbcConfig
JdbcConfig getJdbcConfig()Gets JDBC-specific configuration.- Returns:
- non-null JDBC-specific configuration
-
getJdbcTypeMapping
Gets JDBC type mapping. Same asgetJdbcConfig().getMapper().- Returns:
- non-null JDBC type mapping
-
getMaxInsertBlockSize
long getMaxInsertBlockSize()Gets 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.- Returns:
- value of max_insert_block_size
-
isTransactionSupported
boolean isTransactionSupported()Checks whether transaction is supported.- Returns:
- true if transaction is supported; false otherwise
-
isImplicitTransactionSupported
boolean isImplicitTransactionSupported()Checks whether implicit transaction is supported.- Returns:
- true if implicit transaction is supported; false otherwise
-
newQueryId
String newQueryId()Creates a new query ID.- Returns:
- universal unique query ID
-
parse
@Deprecated default ClickHouseSqlStatement[] parse(String sql, com.clickhouse.client.ClickHouseConfig config) Deprecated.will be removed in 0.5, please useparse(String, ClickHouseConfig, Map)insteadParses the given sql.- Parameters:
sql- sql to parseconfig- configuration which might be used for parsing, could be null- Returns:
- non-null parsed sql statements
-
parse
ClickHouseSqlStatement[] parse(String sql, com.clickhouse.client.ClickHouseConfig config, Map<String, Serializable> settings) Parses the given sql.- Parameters:
sql- sql to parseconfig- configuration which might be used for parsing, could be nullsettings- server settings- Returns:
- non-null parsed sql statements
-
parse(String, ClickHouseConfig, Map)instead