Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ClickHouse JDBC driver in enum DatabaseDriver #42815

Closed
wants to merge 1 commit into from

Conversation

nosan
Copy link
Contributor

@nosan nosan commented Oct 21, 2024

#42799

I referred to the documentation here: https://clickhouse.com/docs/en/integrations/java/jdbc-driver. The documentation mentions the latest version as 0.6.5, but on their GitHub releases page (https://github.com/ClickHouse/clickhouse-java/releases), the latest version is 0.7.0.

I did not use version 0.7.0 because it has a compile dependency on clickhouse-http-client:0.7.0-SNAPSHOT (https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc/0.7.0).

Additionally, I verified the driver locally with the following test:

@Testcontainers(disabledWithoutDocker = true)
class ClickhouseIntegrationTests {

	@Container
	static final ClickHouseContainer clickhouse = new ClickHouseContainer("clickhouse/clickhouse-server:24-alpine")
		.withUsername("test")
		.withPassword("password");

	@Test
	void shouldConnectToClickhouse ()  {
		String jdbcUrl = clickhouse.getJdbcUrl();
		SimpleDriverDataSource dataSource = DataSourceBuilder.create()
			.type(SimpleDriverDataSource.class)
			.url(jdbcUrl)
			.username("test")
			.password("password")
			.build();
		new JdbcTemplate(dataSource).execute(DatabaseDriver.CLICKHOUSE.getValidationQuery());
	}

}

By the way, when I updated the version to 0.7.0, Gradle was against this:

Execution failed for task ':spring-boot-project:spring-boot:compileKotlin'.
> Could not resolve all files for configuration ':spring-boot-project:spring-boot:compileClasspath'.
   > Could not find com.clickhouse:clickhouse-http-client:0.7.0-SNAPSHOT.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/com/clickhouse/clickhouse-http-client/0.7.0-SNAPSHOT/maven-metadata.xml
       - https://repo.maven.apache.org/maven2/com/clickhouse/clickhouse-http-client/0.7.0-SNAPSHOT/clickhouse-http-client-0.7.0-SNAPSHOT.pom
       - https://repo.spring.io/milestone/com/clickhouse/clickhouse-http-client/0.7.0-SNAPSHOT/maven-metadata.xml
       - https://repo.spring.io/milestone/com/clickhouse/clickhouse-http-client/0.7.0-SNAPSHOT/clickhouse-http-client-0.7.0-SNAPSHOT.pom
       - https://repo.spring.io/snapshot/com/clickhouse/clickhouse-http-client/0.7.0-SNAPSHOT/maven-metadata.xml
       - https://repo.spring.io/snapshot/com/clickhouse/clickhouse-http-client/0.7.0-SNAPSHOT/clickhouse-http-client-0.7.0-SNAPSHOT.pom
     Required by:
         project :spring-boot-project:spring-boot > com.clickhouse:clickhouse-jdbc:0.7.0

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 21, 2024
@nosan
Copy link
Contributor Author

nosan commented Oct 21, 2024

0.7.0 could be used but this requires adding an additional module:

modules = [
    "clickhouse-jdbc",
    **"clickhouse-http-client"**
]

@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 22, 2024
@philwebb philwebb self-assigned this Oct 22, 2024
@philwebb philwebb added this to the 3.4.0-RC1 milestone Oct 22, 2024
philwebb pushed a commit that referenced this pull request Oct 22, 2024
@philwebb philwebb closed this in 45c9fc0 Oct 22, 2024
@philwebb
Copy link
Member

Thanks @nosan! Given that we don't really have any direct integration with ClickHouse, I've removed it as a managed dependency. I think this is a good middle ground that means we can support the URLs without needing to worry about which version to depend on.

@nosan
Copy link
Contributor Author

nosan commented Oct 22, 2024

Thank you, @philwebb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants