Turso LibSQL JDBC is a library for accessing and managing LibSQL databases in Java.
- It is a pure Java library
- Version 1.0 uses simple HTTP API protocol for LibSQL
- It supports prepared statements, database metadata, resultsets, data types and most of other JDBC features
- It supports Turso and local LibSQL servers
- It is included in DBeaver and CloudBeaver as default LibSQL driver. However, it can be used in any other products/frameworks which rely on JDBC API
JDBC URL format: jdbc:dbeaver:libsql:<server-url>
Server URL is a full URL including schema and port. For example:
jdbc:dbeaver:libsql:http://localhost:1234
jdbc:dbeaver:libsql:https://test-test.turso.io
Token based authentication supported in version 1.0. Pass token value as password, leave the username empty.
Driver class name: com.dbeaver.jdbc.driver.libsql.LibSqlDriver
import java.sql.*;
public class LibSqlTest {
public static void main(String[] args) throws Exception {
String databaseUrl = "http://libsql-server.company.local:8080";
String token = args[0];
try (Connection connection = DriverManager.getConnection("jdbc:dbeaver:libsql:" + databaseUrl, null, token)) {
try (Statement statement = connection.createStatement()) {
statement.execute("drop table if exists test_table_1");
statement.execute("create table test_table_1 (id integer, name string)");
statement.execute("insert into test_table_1 values(1, 'test one')");
statement.execute("insert into test_table_1 values(2, 'test two')");
try (ResultSet rs = statement.executeQuery("select * from test_table_1")) {
while (rs.next()) {
System.out.println(rs.getInt("id") + " = " + rs.getString("name"));
}
}
}
}
}
}
Licensed under the Apache License, Version 2.0
Download from Maven Central or from the releases page.
<dependencies>
<dependency>
<groupId>com.dbeaver.jdbc</groupId>
<artifactId>com.dbeaver.jdbc.driver.libsql</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>