A library that bundles database drivers for simple use with your plugin


DbLib is a library, that bundles database drivers for simple use with your plugin.

NoteI’m not a maintainer of the plugin, but I can help if you have issues using it with PowerNukkit.
LicenseGNU v3.0
Source codehttps://github.com/Nukkit-coders/DbLib
Issue Trackerhttps://github.com/Nukkit-coders/DbLib/issues


Provides access to popular database engines: SQLite and MySQL; Includes popular library ORMLite, that provides access to database without using SQL-queries; Organizes universal data storage for all plugins, that uses DbLib. Server owner must configure DbLib once and all plugins that use DbLib will work fine!

How to use plugin (Server owners must read this)

If any plugin requires a DbLib you just need to download and install it. Usually, it will be enough. But if you going to use to MySQL or another SQLite file you need to configure plugin (Read at Config section)

Note for plugin developers

If you plugin requires DbLib, please add a direct depend to your plugin.yml, if the dependency is optional then add a softdepend as in the example bellow:

# If required
 - DbLib
# If optional
 - DbLib

ORMLite is popular engine, that provides access to databases using ORM technique. Practically it means that you can read and save data into the database without writing SQL-queries.

DbLib also includes database drivers: SQLite driver MySQL driver If you would not like to use ORMLite, you can use MySQL (or SQLite) drivers as usually, using JDBC provided by Java.

How to connect to universal DbLib storage

DbLib suggests using universal database (by default it is a file nukkit.db, located in server folder or MySQL database defined by the user) for all plugins. If DbLib installed on the server you don’t need to think about database drivers, URLs, names and passwords.

Here is example of creating new table (check API section for more info):




  public boolean connectToDbLib(){
    if (this.getServer().getPluginManager().getPlugin("DbLib") == null){
      this.getLogger().info(TextFormat.RED+"DbLib plugin not found");
      return false;
    connectionSource = DbLib.getConnectionSource();
    if (connectionSource == null) return false;
    try {
      passDao =  DaoManager.createDao(connectionSource, PasswordsTable.class);
      TableUtils.createTableIfNotExists(connectionSource, PasswordsTable.class);
    } catch (Exception e) {
      return false;
    return true;

But if you going to use any other database you must use this method:

DbLib.getConnectionSoruce(String url, String userName, String password)

Category: Developer Tools

Published on Apr 16, 2022




total downloads

Promoted Versions