com.github.housepower.jdbc.settings.ClickHouseConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clickhouse-native-jdbc Show documentation
Show all versions of clickhouse-native-jdbc Show documentation
ClickHouse Native Protocol JDBC implementation
package com.github.housepower.jdbc.settings;
import com.github.housepower.jdbc.misc.Validate;
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ClickHouseConfig {
private int port;
private String address;
private String database;
private String username;
private String password;
private int soTimeout;
private int connectTimeout;
private Map settings;
public static final Pattern DB_PATH_PATTERN = Pattern.compile("/([a-zA-Z0-9_]+)");
private ClickHouseConfig() {
}
public ClickHouseConfig(String url, Properties properties) throws SQLException {
this.settings = parseJDBCUrl(url);
this.settings.putAll(parseJDBCProperties(properties));
Object obj;
this.port = (obj = settings.remove(SettingKey.port)) == null ? 9000 : ((Integer) obj) == -1 ? 9000 : (Integer) obj;
this.address = (obj = settings.remove(SettingKey.address)) == null ? "127.0.0.1" : String.valueOf(obj);
this.password = (obj = settings.remove(SettingKey.password)) == null ? "" : String.valueOf(obj);
this.username = (obj = settings.remove(SettingKey.user)) == null ? "default" : String.valueOf(obj);
this.database = (obj = settings.remove(SettingKey.database)) == null ? "default" : String.valueOf(obj);
this.soTimeout = (obj = settings.remove(SettingKey.query_timeout)) == null ? 0 : (Integer) obj;
this.connectTimeout = (obj = settings.remove(SettingKey.connect_timeout)) == null ? 0 : (Integer) obj;
}
public int port() {
return this.port;
}
public String address() {
return this.address;
}
public String database() {
return this.database;
}
public String username() {
return this.username;
}
public String password() {
return this.password;
}
public int queryTimeout() {
return this.soTimeout;
}
public int connectTimeout() {
return this.connectTimeout;
}
public Map settings() {
return settings;
}
public Map parseJDBCProperties(Properties properties) {
Map settings = new HashMap();
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy