Getting Started with Lealone: High‑Performance Java OLTP Database
This guide introduces Lealone, a Java open‑source high‑performance relational database for OLTP, outlines its key features, provides step‑by‑step instructions for downloading, starting, and using the server and client, shows JDBC CRUD examples, GUI client setup, and links to the author's technical blogs and source notes.
1. Introduction
The author has followed Lealone for years because databases involve networking, protocols, SQL parsing, and storage, and anyone interested in building their own database should not miss Lealone.
2. What is Lealone
Lealone is a Java open‑source high‑performance relational database designed for OLTP scenarios. Version 5.2 is the latest long‑term support (LTS) milestone.
Lealone features:
Extremely high concurrent write performance
Full‑link asynchronous processing with few threads handling massive concurrency
Pause‑able, progressive SQL engine
Priority‑based preemptive scheduling to prevent slow queries from monopolizing CPU
Very fast JDBC connection creation with minimal resources, eliminating the need for a connection pool
Plug‑in storage engine architecture with built‑in AOSE engine using an innovative asynchronous B‑Tree
Plug‑in transaction engine architecture separating transaction logic from storage, with built‑in AOTE engine
Page‑level row‑column mixed storage that saves memory when reading only a few columns from wide tables
Support for creating managed backend services via the CREATE SERVICE statement
Runs from a single JAR of less than 2 MB, no installation required
Supports indexes, views, joins, sub‑queries, triggers, custom functions, ORDER BY, GROUP BY, and aggregation
3. Quick Start
3.1 Requirements
Lealone runs on Java 8 or newer. Install Java if it is not already present.
3.2 Download Lealone
Visit the Lealone GitHub releases page and download the latest JAR, e.g.,
lealone-5.2.0.jar.
3.3 Start Lealone
Open a command‑line window and execute:
java -jar lealone-5.2.0.jar <code>Lealone version: 5.2.0
Use default config
Base dir: .\lealone_data
Init storage engines: 5 ms
Init transaction engines: 67 ms
Init sql engines: 3 ms
Init protocol server engines: 105 ms
Init lealone database: 71 ms
Starting tcp server accepter
TcpServer started, host: 127.0.0.1, port: 9210
Total time: 269 ms (Load config: 8 ms, Init: 256 ms, Start: 5 ms)
Exit with Ctrl+C</code>Press Ctrl + C to stop Lealone.
3.4 Use the Lealone client
Open another command‑line window and run:
java -jar lealone-5.2.0.jar -clientThe default user is
root, connecting to
127.0.0.1:9210with an empty password. The default database is
lealone; use the
-databaseoption to specify another.
<code>Welcome to Lealone Shell 5.2.0
Connect to jdbc:lealone:tcp://localhost:9210/lealone
Commands are case insensitive; SQL statements end with ';'
help or ? Display this help
list Toggle result list / stack trace mode
maxwidth or md Set maximum column width (default is 100)
autocommit or ac Enable or disable autocommit
history or h Show the last 20 statements
reconnect or rc Reconnect the database
quit or exit Close the connection and exit
sql> CREATE TABLE IF NOT EXISTS test (f1 int primary key, f2 long);
(Update count: 0, 7 ms)
sql> INSERT INTO test (f1, f2) VALUES (1, 2);
(Update count: 1, 2 ms)
sql> SELECT * FROM test;
+----+----+
| F1 | F2 |
+----+----+
| 1 | 2 |
+----+----+
(1 row, 8 ms)
sql> UPDATE test SET f2 = 20;
(Update count: 1, 1 ms)
sql> SELECT * FROM test;
+----+----+
| F1 | F2 |
+----+----+
| 1 | 20 |
+----+----+
(1 row, 2 ms)
sql> DELETE FROM test;
(Update count: 1, 2 ms)
sql> SELECT * FROM test;
+----+----+
| F1 | F2 |
+----+----+
+----+----+
(0 rows, 1 ms)</code>3.5 JDBC CRUD Example
Add the driver dependency:
<code><dependencies>
<dependency>
<groupId>org.lealone</groupId>
<artifactId>lealone-client</artifactId>
<version>5.2.0</version>
</dependency>
</dependencies></code>Java CRUD example:
<code>public class CRUDExample {
public static void main(String[] args) throws Exception {
String url = "jdbc:lealone:tcp://localhost:9210/lealone";
Connection conn = DriverManager.getConnection(url, "root", "");
Statement stmt = conn.createStatement();
stmt.executeUpdate("CREATE TABLE IF NOT EXISTS test (f1 int primary key, f2 long)");
stmt.executeUpdate("INSERT INTO test(f1, f2) VALUES(1, 1)");
stmt.executeUpdate("UPDATE test SET f2 = 2 WHERE f1 = 1");
ResultSet rs = stmt.executeQuery("SELECT * FROM test");
while (rs.next()) {
System.out.println("f1=" + rs.getInt(1) + " f2=" + rs.getLong(2));
System.out.println();
}
rs.close();
stmt.executeUpdate("DELETE FROM test WHERE f1 = 1");
stmt.executeUpdate("DROP TABLE IF EXISTS test");
stmt.close();
conn.close();
}
}
</code>mybatis‑plus 3.5.3.2 also adds support for Lealone.
4. GUI Client
You can access Lealone with JDBC GUI tools such as DBeaver, JetBrains DataGrip, etc. For DBeaver, the configuration steps are:
Database → Driver Manager → New
Configure driver class:
org.lealone.client.jdbc.JdbcDriverJDBC URL pattern:
jdbc:lealone:tcp://{host}[:{port}]/[{database}]Add the driver JAR file
5. Author Blog and Source Notes
The author’s blog and technical notes are collected on GitHub:
My Blog
OpenJDK Research
H2 Research
Tomcat Research
Cassandra Research
The author’s posts contain many technical details, breakthroughs, and personal experiences worth reading.
6. Conclusion
If you have scenarios where Lealone fits, give it a try. It is also a good resource for learning database development, and the author’s blogs and source notes are valuable references for anyone interested in database internals.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.