Commit 034cc20d authored by Baoqi's avatar Baoqi
Browse files

add ClickHouse jdbc support

parent e42d2aa5
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -217,6 +217,9 @@ public class DataSourceService extends BaseService{
            case POSTGRESQL:
                separator = "&";
                break;
            case CLICKHOUSE:
                separator = "&";
                break;
            default:
                separator = "&";
                break;
@@ -367,6 +370,10 @@ public class DataSourceService extends BaseService{
                    datasource = JSONObject.parseObject(parameter, SparkDataSource.class);
                    Class.forName(Constants.ORG_APACHE_HIVE_JDBC_HIVE_DRIVER);
                    break;
                case CLICKHOUSE:
                    datasource = JSONObject.parseObject(parameter, ClickHouseDataSource.class);
                    Class.forName(Constants.COM_CLICKHOUSE_JDBC_DRIVER);
                    break;
                default:
                    break;
            }
@@ -428,7 +435,7 @@ public class DataSourceService extends BaseService{
        String address = buildAddress(type, host, port);
        String jdbcUrl = address + "/" + database;
        String separator = "";
        if (Constants.MYSQL.equals(type.name()) || Constants.POSTGRESQL.equals(type.name())) {
        if (Constants.MYSQL.equals(type.name()) || Constants.POSTGRESQL.equals(type.name()) || Constants.CLICKHOUSE.equals(type.name())) {
            separator = "&";
        } else if (Constants.HIVE.equals(type.name()) || Constants.SPARK.equals(type.name())) {
            separator = ";";
@@ -479,6 +486,9 @@ public class DataSourceService extends BaseService{
                }
                sb.deleteCharAt(sb.length() - 1);
            }
        } else if (Constants.CLICKHOUSE.equals(type.name())) {
            sb.append(Constants.JDBC_CLICKHOUSE);
            sb.append(host).append(":").append(port);
        }

        return sb.toString();
+3 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ public class Constants {
    public static final String ORG_POSTGRESQL_DRIVER = "org.postgresql.Driver";
    public static final String COM_MYSQL_JDBC_DRIVER = "com.mysql.jdbc.Driver";
    public static final String ORG_APACHE_HIVE_JDBC_HIVE_DRIVER = "org.apache.hive.jdbc.HiveDriver";
    public static final String COM_CLICKHOUSE_JDBC_DRIVER = "ru.yandex.clickhouse.ClickHouseDriver";

    /**
     * database type
@@ -90,6 +91,7 @@ public class Constants {
    public static final String POSTGRESQL = "POSTGRESQL";
    public static final String HIVE = "HIVE";
    public static final String SPARK = "SPARK";
    public static final String CLICKHOUSE = "CLICKHOUSE";

    /**
     * jdbc url
@@ -97,6 +99,7 @@ public class Constants {
    public static final String JDBC_MYSQL = "jdbc:mysql://";
    public static final String JDBC_POSTGRESQL = "jdbc:postgresql://";
    public static final String JDBC_HIVE_2 = "jdbc:hive2://";
    public static final String JDBC_CLICKHOUSE = "jdbc:clickhouse://";


    public static final String ADDRESS = "address";
+15 −0
Original line number Diff line number Diff line
@@ -371,6 +371,21 @@
			<groupId>com.github.oshi</groupId>
			<artifactId>oshi-core</artifactId>
		</dependency>

		<dependency>
			<groupId>ru.yandex.clickhouse</groupId>
			<artifactId>clickhouse-jdbc</artifactId>
			<exclusions>
				<exclusion>
					<artifactId>com.fasterxml.jackson.core</artifactId>
					<groupId>jackson-core</groupId>
				</exclusion>
				<exclusion>
					<artifactId>com.fasterxml.jackson.core</artifactId>
					<groupId>jackson-databind</groupId>
				</exclusion>
			</exclusions>
		</dependency>
	</dependencies>


+6 −2
Original line number Diff line number Diff line
@@ -602,15 +602,19 @@ public final class Constants {
    public static final String JDBC_POSTGRESQL_CLASS_NAME = "org.postgresql.Driver";

    /**
     * postgresql
     * hive
     */
    public static final String JDBC_HIVE_CLASS_NAME = "org.apache.hive.jdbc.HiveDriver";

    /**
     * postgresql
     * spark
     */
    public static final String JDBC_SPARK_CLASS_NAME = "org.apache.hive.jdbc.HiveDriver";

    /**
     * ClickHouse
     */
    public static final String JDBC_CLICKHOUSE_CLASS_NAME = "ru.yandex.clickhouse.ClickHouseDriver";

    /**
     * spark params constant
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ public enum DbType {
   * 1 postgresql
   * 2 hive
   * 3 spark
   * 4 clickhouse
   */
  MYSQL, POSTGRESQL, HIVE, SPARK
  MYSQL, POSTGRESQL, HIVE, SPARK, CLICKHOUSE
}
Loading