Minecraft 用 SQLite JDBC
这是一个处于维护状态的分支,源自已停止更新的 Minecraft 模组“SQLite JDBC for Minecraft”。它现在追踪最新的 Xerial sqlite-jdbc 版本,并在上游发布新版本时自动更新。
该模组本身不执行任何操作——它将 SQLite JDBC 驱动程序部署到服务器的类路径中,以便其他希望通过 JDBC 读取或写入 .db/.sqlite 文件的插件/模组无需各自捆绑自己的副本。
典型使用者:Dynmap、Plan、LuckPerms、Grim Anti-Cheat,以及任何希望使用嵌入式 SQLite 而不愿自行分发 10MB 原生二进制文件的插件。
jar 包内容
org.xerial:sqlite-jdbc:3.53.0.0 加上针对 Spigot、Forge 1.12、Forge 1.13–1.16、Forge 1.17–1.20、NeoForge 1.21+ 和 Fabric 的最小加载器存根。驱动程序类保持其规范的 org.sqlite.* 路径——无重定位——因此消费者可以通过普通的 Class.forName("org.sqlite.JDBC") 找到它们。META-INF/services/java.sql.Driver 得以保留,使驱动程序能随 DriverManager 自动注册。
Xerial 驱动程序为每个常见平台/架构捆绑了原生 SQLite 二进制文件(linux x64/aarch64、macos x64/arm64、windows x64)。它们在首次使用时被提取到 JVM 的临时目录中。
兼容性
| 加载器 | MC 版本 | 备注 |
|---|---|---|
| Bukkit / Spigot / Paper / Folia / Purpur | 1.8 → current | 放入 plugins/ |
| Fabric | 1.16.1 → current | 需要 Fabric Loader 0.14+ |
| Forge | 1.12 → 1.20 | 通用 jar,无需 Mixins |
| NeoForge | 1.21 → current | 放入 mods/ |
需要 Java 8+。没有 Java 8 的纯 BukkitAPI 服务器(早于 ~1.8.8 的任何版本)将无法加载任何现代 Xerial 版本;这是上游约束,而非本模组的限制。
何时真正需要此模组
CraftBukkit/Spigot/Paper 自 1.4 时代的 ebeans commit 以来,就在服务器的父类加载器上提供了 sqlite-jdbc。插件类加载器优先委托给父级,因此对于默认 JDBC 路径(Class.forName("org.sqlite.JDBC") / DriverManager.getConnection),捆绑的驱动程序始终胜出,无论 plugins/ 中有什么。已在 Paper 1.12.2 和 1.21.11 上经验测试验证。
在以下情况下你需要此模组:
- 你使用的是 Fabric 或 NeoForge —— vanilla Minecraft 根本不提供任何 JDBC 驱动程序
- 你使用的是剥离了捆绑驱动程序的 Bukkit 分支(罕见,但确实发生在精简服务器构建中)
- 你想要比你的服务器捆绑的更新版本的 SQLite 引擎 —— 用于
RETURNING、STRICT表、在 1.8–1.12 服务器上的现代 UPSERT,或者仅仅是为了跟踪最新的 Xerial 版本。参见下文 通过公共 API 使用较新引擎。
通过公共 API 使用较新引擎
默认路径使用捆绑的驱动程序。要改用此模组的驱动程序,你的插件应软依赖此持有者并直接调用 MinecraftSqliteJdbc.connect(url):
// in your plugin.yml
softdepend: [sqlite-jdbc]
// in your plugin code
Connection c;
try {
c = MinecraftSqliteJdbc.connect("jdbc:sqlite:foo.db");
} catch (NoClassDefFoundError | ClassNotFoundException notInstalled) {
// holder isn't installed — fall back to the bundled driver
c = DriverManager.getConnection("jdbc:sqlite:foo.db");
}
MinecraftSqliteJdbc 包装了一个指向此 jar URL 的子优先 URLClassLoader,其父级为平台类加载器,因此 org.sqlite.* 必须来自此 jar(而非捆绑链)。返回的 Connection 是标准的 java.sql.Connection —— 请保持对 java.sql.* 接口的转换;实现类 org.sqlite.SQLiteConnection 位于子优先类加载器中,不会跨边界向下转换。
已在 Paper 1.12.2(捆绑引擎 3.21.0)上验证 —— 相同的 JVM,相同的启动:
baseline DriverManager.getConnection → engine 3.21.0
MinecraftSqliteJdbc.connect() → engine 3.53.0
API 表面(全部为静态方法):
| 方法 | 返回 |
|---|---|
connect(String url) |
通过此驱动程序打开 Connection |
connect(String url, Properties props) |
如上,带属性 |
driver() |
java.sql.Driver 实例 |
engineVersion() |
SQLite 引擎版本(例如 "3.53.0") |
driverVersion() |
驱动程序版本字符串(例如 "3.53.0.0") |
eagerInit() |
在插件启用时预热类加载器 |
shutdown() |
在插件禁用时释放文件句柄 + JNI |
Grim Anti-Cheat 的 SQLite 后端在此持有者安装且提供的引擎比捆绑的更新时会自动使用此 API —— 参见 Grim 的 Database wiki page。
常见 Bukkit 分支上捆绑的 SQLite 引擎版本
如果你想知道你的服务器实际捆绑了什么引擎版本,供参考:
| CraftBukkit / Paper 分支 | 捆绑的 SQLite 引擎 |
|---|---|
| 1.8 – 1.10 | 3.7.2 |
| 1.11 | 3.16.1 |
| 1.12 | 3.21.0.1 |
| 1.13 | 3.25.2 |
| 1.14 | 3.28.0 |
| 1.15 | 3.30.1 |
| 1.16 – 1.17 | 3.34.0 |
| 1.20.6 | 3.45.3.0 |
| Paper 1.21.4 | 3.47.0.0 |
| Paper 1.21.5 – 1.21.11 | 3.49.1.0 |
| master / 26.x | 3.51.3.0 |
此模组提供引擎 3.53.0.0(或最新 Xerial 发布的任何版本),但在 Bukkit 家族服务器上这都不重要 —— 实际运行查询的是捆绑的引擎。如果你需要较新引擎的功能,如 RETURNING(3.35+)或 STRICT 表(3.37+),请升级到捆绑了足够近期驱动的 Paper 版本,或将该工作负载移至 Fabric/NeoForge,在那里你可以控制驱动程序。
从插件或模组中使用它
将 sqlite-jdbc 声明为 compileOnly:
compileOnly("org.xerial:sqlite-jdbc:3.53.0.0")
在启动时探测:
try {
Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
getLogger().warning("SQLite backend disabled — install minecraft-sqlite-jdbc");
return;
}
try (Connection c = DriverManager.getConnection("jdbc:sqlite:" + dataDir.resolve("data.db"))) {
// ...
}
在 Paper 1.17+ 中,每个插件的类加载器都是隔离的。将此模组添加到你的 plugin.yml 的 softdepend 中,以便让驱动类对插件可见:
softdepend: [minecraft-sqlite-jdbc]
Fabric 和 NeoForge 将所有模组统一在一个类加载器上,因此无需在那里进行等效声明。
版本说明
Jar 包的版本号与 Xerial 的 sqlite-jdbc 发行版一一对应。3.53.0.0+2026-04-14 搭载引擎版本 3.53.0.0;后缀为构建日期。计划中的 GitHub Action 每天检查 Maven Central —— 当 Xerial 发布新版本时,会自动在此处打开一个自动合并 PR,并且 Modrinth 上的资源包也会自动发布。
许可证
Apache 2.0(Xerial / Taro L. Saito)。重新打包未添加任何功能变更,并继承该许可证。完整文本见 LICENSE。
问题反馈、源代码:GitHub。
SQLite JDBC for Minecraft
A maintained fork of the dormant SQLite JDBC for Minecraft mod, now tracking the latest Xerial sqlite-jdbc release with auto-bumps whenever upstream cuts a new version.
The mod does nothing on its own — it ships the SQLite JDBC driver onto the server's classpath so other plugins/mods that want to read or write .db/.sqlite files via JDBC don't each have to bundle their own copy.
Typical consumers: Dynmap, Plan, LuckPerms, Grim Anti-Cheat, and any plugin that wants embedded SQLite without redistributing 10MB of native binaries themselves.
What's in the jar
org.xerial:sqlite-jdbc:3.53.0.0 plus minimal loader stubs for Spigot, Forge 1.12, Forge 1.13–1.16, Forge 1.17–1.20, NeoForge 1.21+, and Fabric. The driver classes stay at their canonical org.sqlite.* paths — no relocation — so consumers find them with plain Class.forName("org.sqlite.JDBC"). META-INF/services/java.sql.Driver is preserved so the driver auto-registers with DriverManager.
The xerial driver bundles native SQLite binaries for every common platform/architecture (linux x64/aarch64, macos x64/arm64, windows x64). They get extracted to the JVM's tempdir on first use.
Compatibility
| Loader | MC versions | Notes |
|---|---|---|
| Bukkit / Spigot / Paper / Folia / Purpur | 1.8 → current | drop into plugins/ |
| Fabric | 1.16.1 → current | needs Fabric Loader 0.14+ |
| Forge | 1.12 → 1.20 | universal jar, no Mixins |
| NeoForge | 1.21 → current | drop into mods/ |
Java 8+ required. Plain BukkitAPI servers without Java 8 (anything older than ~1.8.8) won't be able to load any modern xerial release; that's an upstream constraint, not this mod.
When you actually need this mod
CraftBukkit/Spigot/Paper have shipped sqlite-jdbc on the server's parent classloader since the 1.4-era ebeans commit. Plugin classloaders delegate parent-first, so for the default JDBC path (Class.forName("org.sqlite.JDBC") / DriverManager.getConnection) the bundled driver always wins, regardless of what's in plugins/. Tested empirically on Paper 1.12.2 and 1.21.11.
You need this mod when:
- You're on Fabric or NeoForge — vanilla Minecraft ships no JDBC drivers at all
- You're on a Bukkit fork that's stripped the bundled driver (rare, but happens on minified server builds)
- You want a newer SQLite engine version than your server bundles — for
RETURNING,STRICTtables, modern UPSERT on a 1.8–1.12 server, or just to track the latest Xerial release. See Using a newer engine via the public API below.
Using a newer engine via the public API
The default path uses the bundled driver. To use this mod's driver instead, your plugin softdepends on this holder and calls MinecraftSqliteJdbc.connect(url) directly:
// in your plugin.yml
softdepend: [sqlite-jdbc]
// in your plugin code
Connection c;
try {
c = MinecraftSqliteJdbc.connect("jdbc:sqlite:foo.db");
} catch (NoClassDefFoundError | ClassNotFoundException notInstalled) {
// holder isn't installed — fall back to the bundled driver
c = DriverManager.getConnection("jdbc:sqlite:foo.db");
}
MinecraftSqliteJdbc wraps a child-first URLClassLoader pointing at this jar's URL, parented to the platform classloader so org.sqlite.* must come from this jar (not the bundled chain). The returned Connection is a standard java.sql.Connection — keep your casts to java.sql.* interfaces; the impl class org.sqlite.SQLiteConnection lives in the child-first classloader and won't down-cast across the boundary.
Verified on Paper 1.12.2 (bundled engine 3.21.0) — same JVM, same boot:
baseline DriverManager.getConnection → engine 3.21.0
MinecraftSqliteJdbc.connect() → engine 3.53.0
API surface (all static):
| Method | Returns |
|---|---|
connect(String url) |
open Connection through this driver |
connect(String url, Properties props) |
as above with props |
driver() |
the java.sql.Driver instance |
engineVersion() |
SQLite engine version (e.g. "3.53.0") |
driverVersion() |
driver version string (e.g. "3.53.0.0") |
eagerInit() |
warm the classloader at plugin enable |
shutdown() |
release file handles + JNI on plugin disable |
Grim Anti-Cheat's SQLite backend uses this API automatically when this holder is installed and ships a newer engine than the bundled one — see Grim's Database wiki page.
Bundled SQLite engine versions on common Bukkit lines
For reference if you're wondering what engine version your server actually ships:
| CraftBukkit / Paper line | Bundled SQLite engine |
|---|---|
| 1.8 – 1.10 | 3.7.2 |
| 1.11 | 3.16.1 |
| 1.12 | 3.21.0.1 |
| 1.13 | 3.25.2 |
| 1.14 | 3.28.0 |
| 1.15 | 3.30.1 |
| 1.16 – 1.17 | 3.34.0 |
| 1.20.6 | 3.45.3.0 |
| Paper 1.21.4 | 3.47.0.0 |
| Paper 1.21.5 – 1.21.11 | 3.49.1.0 |
| master / 26.x | 3.51.3.0 |
This mod ships engine 3.53.0.0 (or whatever the latest xerial release is), but none of that matters on Bukkit-family servers — the bundled engine is what actually runs your queries. If you need a newer engine for features like RETURNING (3.35+) or STRICT tables (3.37+), upgrade to a Paper version that bundles a recent enough driver, or move that workload to Fabric/NeoForge where you can control the driver.
Using it from a plugin or mod
Declare sqlite-jdbc as compileOnly:
compileOnly("org.xerial:sqlite-jdbc:3.53.0.0")
Probe at startup:
try {
Class.forName("org.sqlite.JDBC");
} catch (ClassNotFoundException e) {
getLogger().warning("SQLite backend disabled — install minecraft-sqlite-jdbc");
return;
}
try (Connection c = DriverManager.getConnection("jdbc:sqlite:" + dataDir.resolve("data.db"))) {
// ...
}
On Paper 1.17+ each plugin's classloader is isolated. Add this mod to your plugin.yml softdepend so the driver classes are visible to your plugin:
softdepend: [minecraft-sqlite-jdbc]
Fabric and NeoForge unify all mods on one classloader, so no equivalent declaration is needed there.
Versioning
The jar version tracks Xerial's sqlite-jdbc release one-to-one. 3.53.0.0+2026-04-14 ships engine 3.53.0.0; the suffix is the build date. A scheduled GitHub Action checks Maven Central daily — when xerial cuts a new release, an auto-merge PR opens here and the Modrinth release goes out automatically.
License
Apache 2.0 (Xerial / Taro L. Saito). The repackage adds no functional changes and inherits that license. Full text in LICENSE.
Issues, source: GitHub.
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Minecraft SQLite JDBC
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
ci:发布兼容 Fabric 游戏版本的 holders
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
PacketEvents 是一款专为 Minecraft Java 版打造的协议库,旨在简化数据包的处理与传输。
插件
ExyliaPlugins 的库。
插件
通过对话框或铁砧界面帮助你的 Anthme
插件
重新定义服务器上的生物运输方式。使用高度可定制的口袋道具,安全地捕获、存储和释放任何实体。
插件
为基于 Spigot/Paper/Folia 的服务器添加对 Vivecraft 的支持
插件
用于绘制游戏内地图或在浏览器中随探索实时进行地图绘制的实时地图。
评论 0
登录后参与评分
还没有评论,来抢沙发吧