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
`protected String` `database`
`protected static String` `DEFAULT_DATABASE`
`protected ClickHouseDriver` `driver`
`protected String` `host`
`protected int` `loginTimeout`
`protected int` `port`
`protected String` `url`
`protected static Pattern` `urlRegexp`

### Constructor Summary

Constructors
Constructor and Description
`ClickHouseDataSource(String url)`
`ClickHouseDataSource(String url, ClickHouseProperties properties)`
`ClickHouseDataSource(String url, Properties info)`

### Method Summary

All Methods Instance Methods Concrete Methods
`Connection` `getConnection()`
`Connection` `getConnection(String username, String password)`
`String` `getDatabase()`
`String` `getHost()`
`int` `getLoginTimeout()`
`PrintWriter` `getLogWriter()`
`Logger` `getParentLogger()`
`int` `getPort()`
`ClickHouseProperties` `getProperties()`
`String` `getUrl()`
`boolean` `isWrapperFor(Class<?> iface)`
`void` `setLoginTimeout(int seconds)`
`void` `setLogWriter(PrintWriter out)`
`<T> T` `unwrap(Class<T> iface)`
`ClickHouseDataSource` `withConnectionsCleaning(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`

### Field Detail

#### urlRegexp

    protected static final Pattern urlRegexp

#### DEFAULT_DATABASE

    protected static final String DEFAULT_DATABASE

See Also:
  Constant Field Values

#### driver

    protected final ClickHouseDriver driver

#### url

    protected final String url

#### host

    protected String host

#### port

    protected int port

#### database

    protected String database

#### loginTimeout

    protected int loginTimeout

### 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 Connection getConnection()
                             throws SQLException

Specified by:
  `getConnection` in interface `DataSource`
Throws:
  `SQLException`

#### getConnection

    public Connection getConnection(String username,
                                    String password)
                             throws SQLException

Specified by:
  `getConnection` in interface `DataSource`
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:
  `getLogWriter` in interface `CommonDataSource`
Throws:
  `SQLException`

#### setLogWriter

    public void setLogWriter(PrintWriter out)
                      throws SQLException

Specified by:
  `setLogWriter` in interface `CommonDataSource`
Throws:
  `SQLException`

#### setLoginTimeout

    public void setLoginTimeout(int seconds)
                         throws SQLException

Specified by:
  `setLoginTimeout` in interface `CommonDataSource`
Throws:
  `SQLException`

#### getLoginTimeout

    public int getLoginTimeout()
                        throws SQLException

Specified by:
  `getLoginTimeout` in interface `CommonDataSource`
Throws:
  `SQLException`

#### getParentLogger

    public Logger getParentLogger()
                           throws SQLFeatureNotSupportedException

Specified by:
  `getParentLogger` in interface `CommonDataSource`
Throws:
  `SQLFeatureNotSupportedException`

#### unwrap

    public <T> T unwrap(Class<T> iface)
                 throws SQLException

Specified by:
  `unwrap` in interface `Wrapper`
Throws:
  `SQLException`

#### isWrapperFor

    public boolean isWrapperFor(Class<?> iface)
                         throws SQLException

Specified by:
  `isWrapperFor` in interface `Wrapper`
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` -
  `timeUnit` -
Returns:
  this