mirror of
https://github.com/allankoechke/turso.git
synced 2026-11-30 11:12:58 +00:00
Database had five public ways to open a connection: connect, connect_with_encryption, connect_with_page_codec, connect_async and connect_with_encryption_async. Every new connection setting needs more variants, and the async path doubles them again. Database::connect and Database::connect_async now take a ConnectOpts that holds the encryption key and the page codec, and the other three variants are removed. ConnectOpts has no Default, so every caller goes through ConnectOpts::new() and a required argument added there later makes the compiler find every call site.
Turso JDBC Driver
The Turso JDBC driver is a library for accessing and creating Turso database files using Java.
Project Status
The project is actively developed. Feel free to open issues and contribute.
To view related works, visit this issue.
How to use
Currently, we have not published to the maven central. Instead, you can locally build the jar and deploy it to maven local to use it.
Build jar and publish to maven local
$ cd bindings/java
# Please select the appropriate target platform, currently supports `macos_x86`, `macos_arm64`, `windows` and `linux_x86`
$ make macos_x86
# deploy to maven local
$ make publish_local
Now you can use the dependency as follows:
dependencies {
implementation("tech.turso:turso:0.0.1-SNAPSHOT")
}
Code style
- Favor composition over inheritance. For example,
JDBC4Connectiondoesn't implementTursoConnection. Instead, it includesTursoConnectionas a field. This approach allows us to preserve the characteristics of Turso usingTursoConnectioneasily while maintaining interoperability with the Java world usingJDBC4Connection.