Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

68 Commits

Repository files navigation

chdb Java FFM binding

chdb Java

chdb-java-ffm is Java 22+ JEP 454: Foreign Function & Memory API bind for chdb.

Get started

  • Please add the following dependency to pom.xml:
<dependency>
<groupId>org.mvnsearch</groupId>
<artifactId>chdb-java-ffm</artifactId>
<version>0.2.0</version>
</dependency>
publicclassChdbConnectionTest {
@AutoCloseprivatestaticConnectionconn;
@BeforeAllpublicstaticvoidsetUp() throwsException {
Stringurl = "jdbc:chdb::memory:";
conn = DriverManager.getConnection(url);
}
@TestpublicvoidtestConnection() throwsSQLException {
Stringsql = "select * from file('src/test/resources/logs.csv','CSV')";
Statementstatement = conn.createStatement();
ResultSetresultSet = statement.executeQuery(sql);
while (resultSet.next()) {
System.out.println(resultSet.getString("level"));
}
}
}

chdb JDBC

JDBC URLs:

  • jdbc:chdb::memory:: in-memory database, path is :memory:
  • jdbc:chdb:/path/to/db: database from file path, and both relative and absolute paths supported.

Development setup

  • Download and install JDK 22
  • Download and install jextract
  • Execute update_libchdb.sh to download dynamic library

FAQ

How to load dynamic library from other path?

Execute ln -s /usr/local/lib/libchdb.so libchdb.dylib to link the dynamic library to the current directory.

Update operation support?

Now only query support, and update will be implemented in the future.

PreparedStatement support?

Now PreparedStatement implement is not real, just fake implement friendly for libraries and frameworks.

Spring Jdbc support?

Yes, you can use JdbcTemplate with chdb-java-ffm.

How it works?

Java -> FFM -> chdb(embedded) -> JSON Output -> ResultSet.

Attention: chdb-java-ffm uses Jackson for JSON parsing.

References

  • JEP 454: Foreign Function & Memory API
  • jextract: a tool which mechanically generates Java bindings from native library headers
  • chdb-java: chdb JNI version
  • clickhouse-java: Java client and JDBC driver for ClickHouse

About

chdb with Java FFM(Foreign Function & Memory) binding

Topics

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages