Package ru.yandex.clickhouse
Class ClickHouseDataSource
- java.lang.Object
-
- ru.yandex.clickhouse.ClickHouseDataSource
-
- All Implemented Interfaces:
Wrapper,CommonDataSource,DataSource
public class ClickHouseDataSource extends Object implements DataSource
-
-
Field Summary
Fields Modifier and Type Field Description protected ClickHouseDriverdriverprotected intloginTimeoutSecondsprotected PrintWriterprintWriterprotected Stringurl
-
Constructor Summary
Constructors Constructor Description ClickHouseDataSource(String url)ClickHouseDataSource(String url, Properties info)ClickHouseDataSource(String url, ClickHouseProperties properties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClickHouseConnectiongetConnection()ClickHouseConnectiongetConnection(String username, String password)StringgetDatabase()StringgetHost()intgetLoginTimeout()PrintWritergetLogWriter()LoggergetParentLogger()intgetPort()ClickHousePropertiesgetProperties()StringgetUrl()booleanisWrapperFor(Class<?> iface)voidsetLoginTimeout(int seconds)voidsetLogWriter(PrintWriter out)<T> Tunwrap(Class<T> iface)ClickHouseDataSourcewithConnectionsCleaning(int rate, TimeUnit timeUnit)Schedules connections cleaning at a rate.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
-
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
-
-
-
Field Detail
-
driver
protected final ClickHouseDriver driver
-
url
protected final String url
-
printWriter
protected PrintWriter printWriter
-
loginTimeoutSeconds
protected int loginTimeoutSeconds
-
-
Constructor Detail
-
ClickHouseDataSource
public ClickHouseDataSource(String url)
-
ClickHouseDataSource
public ClickHouseDataSource(String url, Properties info)
-
ClickHouseDataSource
public ClickHouseDataSource(String url, ClickHouseProperties properties)
-
-
Method Detail
-
getConnection
public ClickHouseConnection getConnection() throws SQLException
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getConnection
public ClickHouseConnection getConnection(String username, String password) throws SQLException
- Specified by:
getConnectionin interfaceDataSource- Throws:
SQLException
-
getHost
public String getHost()
-
getPort
public int getPort()
-
getDatabase
public String getDatabase()
-
getUrl
public String getUrl()
-
getProperties
public ClickHouseProperties getProperties()
-
getLogWriter
public PrintWriter getLogWriter() throws SQLException
- Specified by:
getLogWriterin interfaceCommonDataSource- Specified by:
getLogWriterin interfaceDataSource- Throws:
SQLException
-
setLogWriter
public void setLogWriter(PrintWriter out) throws SQLException
- Specified by:
setLogWriterin interfaceCommonDataSource- Specified by:
setLogWriterin interfaceDataSource- Throws:
SQLException
-
setLoginTimeout
public void setLoginTimeout(int seconds) throws SQLException- Specified by:
setLoginTimeoutin interfaceCommonDataSource- Specified by:
setLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
getLoginTimeout
public int getLoginTimeout() throws SQLException- Specified by:
getLoginTimeoutin interfaceCommonDataSource- Specified by:
getLoginTimeoutin interfaceDataSource- Throws:
SQLException
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLoggerin interfaceCommonDataSource- Throws:
SQLFeatureNotSupportedException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
withConnectionsCleaning
public ClickHouseDataSource withConnectionsCleaning(int rate, TimeUnit timeUnit)
Schedules connections cleaning at a rate. Turned off by default. See https://hc.apache.org/httpcomponents-client-4.5.x/tutorial/html/connmgmt.html#d5e418- Parameters:
rate- period when checking would be performedtimeUnit- time unit of rate- Returns:
- current modified object
-
-