Welcome to libsql-java. This repository implements a pure-Java JDBC driver, client library, and protocol codec for libSQL / sqld over the Hrana protocol.
This guide provides developers and automated AI agents with instructions on architecture, tooling, build conventions, and verification workflows.
- Java Version: Java LTS.
- Environment Management: Tooling is managed via mise (
mise.toml). - Build System: Maven with the included wrapper (
./mvnw). - Container Runtime: Docker or Podman (with socket exposed) for Testcontainers.
# Ensure correct Java LTS environment
mise install
# Verify Java & Maven
mise exec -- java -version
mise exec -- ./mvnw -versionlibsql-java/
├── libsql-hrana-codec/ # Core protocol data structures & DirectHranaJsonCodec
├── libsql-client/ # Low-level HTTP transport, baton state management, pipeline queue
├── libsql-jdbc/ # Standard JDBC 4.3 driver (java.sql.* implementation)
├── libsql-itests/ # Testcontainers (sqld) and Toxiproxy integration tests
└── vendor/ # Upstream specifications and documentation (Hrana v3, sqld)
-
libsql-hrana-codec:- Zero external runtime dependencies.
DirectHranaJsonCodechandles streaming JSON encoding/decoding directly for maximum performance.- Preserves 64-bit integer precision and binary base64 encoding.
-
libsql-client:- Built on
java.net.http.HttpClientwith pooled connection reuse. - Manages baton lifecycle,
/v3/pipelineexecution, and stream close handshakes.
- Built on
-
libsql-jdbc:- Standards-compliant JDBC 4.3 implementation.
- Maps URL schemes:
jdbc:libsql:http://...,jdbc:libsql:https://..., andjdbc:sqlite:http://.... - Maps SQLite dynamic typing to JDBC SQL types and translates Hrana error codes to
SQLExceptionhierarchies.
-
libsql-itests:- All tests run against containerized
sqld(ghcr.io/tursodatabase/libsql-server:latest). - Includes HikariCP connection pool churn tests and Toxiproxy network toxicity tests.
- All tests run against containerized
We enforce code hygiene using Spotless:
- Format check:
mise exec -- ./mvnw spotless:check - Apply format:
mise exec -- ./mvnw spotless:apply
CI will fail if files contain trailing whitespace, missing newline terminations, or formatting violations. Run spotless:apply before submitting changes.
mise exec -- ./mvnw testRequires a running Docker or Podman daemon:
mise exec -- ./mvnw clean verifyTo run a specific test:
mise exec -- ./mvnw -pl libsql-itests -Dtest=HikariCpIntegrationIT test- Clean Commits: Use Conventional Commits (e.g.
feat(jdbc): ...,fix(codec): ...,docs: ...). - No Proprietary Information: Never commit credentials, private tokens, internal corporate urls, or proprietary notices.
- Dependency Minimization: Keep runtime dependencies minimal. Client and codec modules should remain lightweight.
- Error Handling: Do not swallow exceptions. Map protocol or transport errors into appropriate
SQLExceptionorLibsqlExceptiontypes.