有人用过 Spring JDBC 和 Clickhouse 吗?驱动程序类名是什么?
spring.datasource.driver-class-name=<what is it?>
我想可能就是这样,尽管它看起来不像我见过的任何其他驱动程序类名称。
spring.datasource.driver-class-name=ru.yandex.clickhouse.ClickHouseDriver
还有比官方驱动程序版本更轻、更快的替代方案 - clickhouse4j。 (官方驱动程序的分支,有一些改进)
你可以这样使用它:
spring.datasource.driver-class-name=cc.blynk.clickhouse.ClickHouseDriver
由于将 vom yandex 移至 clickhouse.com,驱动程序已重命名。
Clickhouse 驱动程序
spring.datasource.driver-class-name=com.clickhouse.jdbc.ClickHouseDriver
参见https://github.com/ClickHouse/clickhouse-jdbc
另请注意 Java 客户端和 JDBC 驱动程序 MVN 依赖关系也发生了变化:
Maven Clickhouse Java 客户端
<dependency>
<groupId>com.clickhouse</groupId>
<!-- or clickhouse-grpc-client if you prefer gRPC -->
<artifactId>clickhouse-http-client</artifactId>
<version>0.3.2-patch11</version>
</dependency>
Maven Clickhouse JDBC 驱动程序
<dependency>
<!-- please stop using ru.yandex.clickhouse as it's been deprecated -->
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.2-patch11</version>
<!-- use uber jar with all dependencies included, change classifier to http for smaller jar -->
<classifier>all</classifier>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
从 4.0.0 开始,yandex 软件包将被删除并且无法运行!
这是我将 ClickHouseDriver 与 Hibernate 连接的配置:
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
Configuration createConfiguration() {
Configuration configuration = new Configuration();
configuration.setProperty(AvailableSettings.JAKARTA_JDBC_URL,"clickhouse.uri");
configuration.setProperty(AvailableSettings.JAKARTA_JDBC_USER,"clickhouse.login");
configuration.setProperty(AvailableSettings.JAKARTA_JDBC_PASSWORD,"clickhouse.password");
configuration.setProperty(AvailableSettings.JAKARTA_JDBC_DRIVER,"com.clickhouse.jdbc.ClickHouseDriver");
}
Maven 依赖:
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.5.0</version>
</dependency>