I would highly suggest using Bukkit's plugin databases API instead of this plugin.


SQLibrary was taken over from alta189 by PatPeter. So far it has support for 13 databases, a factory, and one query builder.


First, add these elements to your pom.xml if you're using Maven:

  <name>Dakani Nexus Repo</name>


You should always save implementations to a superclass, unless that child class has more functionality. So, start off by creating your variable:

private Database sql;

Constructing your database object can be either hardcoded into the definition, or assigned in the method. The constructor does not automatically open the database connection so that it does not have to throw an SQLException (though this was considered for quite some time). Below are the constructors for the most popular databases: MySQL, SQLite, and H2.

sql = new MySQL(Logger.getLogger("Minecraft"), 
            "[MyPlugin] ", 
sql = new SQLite(Logger.getLogger("Minecraft"), 
             "[MyPlugin] ", 
sql = new H2(Logger.getLogger("Minecraft"), 
         "[MyPlugin] ", 

For SQLite and H2, the extension is optional but will default to ".db". For MySQL, the hostname and port number are optional, but will default to those values. Next, we need to open our database connection:

if (sql.open()) {
    // ...

If you know that your plugin will only use the database intermittently, you should check to see if it is open first:

if (!sql.isOpen()) {

If any errors occur while opening the database connection, they will print to console.

Supported Databases

  1. Firebird
  2. FrontBase
  3. DB2
  4. H2
  5. Informix
  6. Ingres
  7. MaxDB
  8. MicrosoftSQL
  9. MySQL
  10. Mongo
  11. mSQL
  12. Oracle
  13. Ovrimos
  14. PostgreSQL
  15. SQLite


  1. Download the jar.
  2. In Eclipse, go to Project Properties ==> Java Build Path ==> Add External Jar and add SQLibrary.jar.
  3. Tell your users to install SQLibrary.jar along with your plugin

Do not install from source!

If you install SQLibrary directly into your plugin, the following bad things will occur:

  1. You cannot run your plugin alongside SQLibrary.jar plugins. Bukkit will (usually) find the SQLibrary classes in your plugin first, and block the SQLibrary.jar dependency.
  2. You cannot run your plugin alongside other plugins using SQLibrary directly from source. Same issue.
  3. Updating will definitely cause these problems and cause you much pain.

Download SQLibrary from your plugin

You can now place this code in your plugin to download and load SQLibrary from your plugin at runtime:


Special Thanks

  • alta189, for starting this library.
  • Belphemur, for adding the first version of our factory package.
  • omwah, for adding Maven to SQLibrary.
  • moose51789, for adding Spout support.
  • Mitsugaru, for hosting our Maven repository, finding bugs, and making fixes.
  • max9403, for supplying the code to download SQLibrary at runtime.

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of PatPeter PatPeter Jul 05, 2015 at 08:33 UTC - 0 likes

    @moose517: Go

    Do you have the JDBC driver for Mongo and have you placed it in the lib directory of your server? I was trying to get this plugin to do this (another reason I made it a plugin instead of a source package), but I don't believe I ever got it working.

  • Avatar of PatPeter PatPeter Jul 05, 2015 at 08:32 UTC - 0 likes

    @CraftBang: Go

    H2 is faster than SQLite. I know that for a fact. SQLite is a more universal format though.

  • Avatar of PatPeter PatPeter Jul 05, 2015 at 08:31 UTC - 0 likes

    @Razorax: Go

    If I could +1 your comment I would Razorax. Gave me quite a chuckle.

    I've done a lot of research into this Ebeans ORM that's built into Bukkit, and to be honest an ORM was what I wanted SQLibrary to become. You can see that in the query builders I had started to develop when I actively maintained this plugin.

    It is based on this research that I believe every Minecraft plugin developer should learn how JPA generation works (which will look very good on a resume as well) and use Ebeans for a database layer.

  • Avatar of Razorax Razorax Jun 29, 2015 at 09:53 UTC - 0 likes

    Who is the "I" in "I would highly suggest using Bukkit's plugin databases API instead of this plugin."? Is it a Bukkit Nazi Dev? Or is it the author/current maintainer of this plugin?

  • Avatar of SableDnah SableDnah Apr 30, 2015 at 16:07 UTC - 0 likes

    @julib5432112345: Go

    Why's it need one? It works fine on craftbukkit and spigot?

    "All this technology and it still takes forever to get anywhere" [ Donate ] [ Twitter ]

    Mob HealthLegendQuest
    Mob Health: Simple damage reporting.LegendQuest: Complete RPG plugin.
  • Avatar of julib5432112345 julib5432112345 Apr 30, 2015 at 16:00 UTC - 0 likes

    Why no update?

  • Avatar of SableDnah SableDnah Apr 29, 2015 at 12:39 UTC - 0 likes

    @CraftBang: Go

    MySQL can (and often does) run on same machine. And if you have a website on the same box then that can read from the same MySQL.

  • Avatar of CraftBang CraftBang Apr 29, 2015 at 11:26 UTC - 0 likes

    So there are a lot of database types your plugin supports.. I can't choose which one to use, I would like to save the data on disk (not online), so MySQL is already gone. Which one would you prefer to be the fastest/best?

    Thanks in advance

    Last edited Apr 29, 2015 by CraftBang
  • Avatar of moose517 moose517 Mar 11, 2015 at 01:48 UTC - 0 likes

    Anyone used mongo at all that can tell me what else is needed for it to work. Get seror that class not found for jdbc.mongod

  • Avatar of funnygatt funnygatt Feb 13, 2015 at 11:33 UTC - 0 likes

    Since I had this problem, I thought post it. The dependency tags for Maven are wrong in the post.


    This is the updated version.

    We are all born ignorant, but one must work hard to remain stupid. - Benjamin Franklin
    Today you are You, that is truer than true. There is no one alive who is Youer than You. - Dr. Seuss

    That moment when you realise you pass 1,000 posts... I must be old...

    Most of us S( c | k )ripters have moved to http://forums.skunity.com/!


Date created
Aug 25, 2012
Last update
Jan 14, 2014
Development stage
  • enUS
Creative Commons — Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0)
Curse link
Recent files