-
Notifications
You must be signed in to change notification settings - Fork 623
Expand file tree
/
Copy pathDataSourceImpl.java
More file actions
83 lines (66 loc) · 2.38 KB
/
DataSourceImpl.java
File metadata and controls
83 lines (66 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.clickhouse.jdbc;
import com.clickhouse.jdbc.internal.ExceptionUtils;
import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;
public class DataSourceImpl implements DataSource, JdbcV2Wrapper {
private static final Logger log = Logger.getLogger(DataSourceImpl.class.getName());
private String url;
private Properties info;
private final Driver driver;
private PrintWriter logWriter;
public void setUrl(String url) {
this.url = url;
}
private Properties getProperties() {
Properties copy = new Properties();
copy.putAll(info);
return copy;
}
public void setProperties(Properties info) {
this.info = info;
}
public DataSourceImpl() {//No-arg constructor required by the standard
this(null, new Properties());
}
public DataSourceImpl(String url, Properties info) {
this.url = url;
this.info = info;
this.driver = new Driver(this);
}
@Override
public Connection getConnection() throws SQLException {
return driver.connect(this.url, this.info);
}
@Override
public Connection getConnection(String username, String password) throws SQLException {
Properties info = getProperties();
info.setProperty("user", username);
info.setProperty("password", password);
return driver.connect(this.url, info);
}
@Override
public PrintWriter getLogWriter() throws SQLException {
return logWriter;
}
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
logWriter = out;
}
@Override
public void setLoginTimeout(int seconds) throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
@Override
public int getLoginTimeout() throws SQLException {
throw new SQLFeatureNotSupportedException("Method not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException("Method not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}