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 ThomasRaud ThomasRaud Sep 26, 2014 at 04:24 UTC - 0 likes

    Problem for using java8u20, reccomended version java is 7u22 or first 8.0(same as 7u22 but 8.0 readdy)

    CubeHex Thomasraud is here to help! If you looking help for WebSend and SMS Service, go to: WebSendHelp

    We try to build our HomePage, but its take a time! If you like to see our webseite development.. go ahead: HomePageDev

  • Avatar of dori99xd dori99xd Aug 24, 2014 at 12:05 UTC - 0 likes

    I' am getting an error:

    [13:59:23 INFO]: [SQLibrary] Loading SQLibrary v7.1 [13:59:23 INFO]: [Tials-Core] Loading Tials-Core v3.7 [13:59:23 INFO]: [SQLibrary] Enabling SQLibrary v7.1 [13:59:23 INFO]: SQLibrary loaded. [13:59:23 INFO]: [Tials-Core] Enabling Tials-Core v3.7 [13:59:23 ERROR]: [MyPlugin][H2] H2 driver class missing: org.h2.D river.

    And my code:

    public static Database database;

    public void onEnable() { database = new lib.PatPeter.SQLibrary.H2(Logger.getLogger("Minecraft"), "[MyPlugin]", this.getDataFolder().getAbsolutePath(), "MyPlugin", ".h2"); database.open(); }

    SqlLibary is in the Build Path as Libary and is in the plugin Folder....

  • Avatar of selfservice0 selfservice0 Jul 22, 2014 at 17:49 UTC - 0 likes

    @Mitsugaru: Go

    I tried bukkit 1.7.10 builds same thing happens. It only happens when I add SQLibrary.

    Send me your paypal and a link to the 1.7.10 build in pm please :D. I'll test it out and send you a reward if it solves the problem.

    PS: Basically what is happening is Skript uses sqlibrary for sql database connections. Skript itself runs fine in 1.7.10 and can store in alternative databases on 1.7.10 with no issue. But as soon as I add SQLibrary and have a moderate size mysql database (I lowered it from over 300,000 rows to 22,000 rows. still won't work) the server freezes as it tries to slowly load the sql database. In bukkit builds prior to 1.7.10 the database loads within a few seconds. After 1.7.10 it seems to load a few rows every few seconds, which is extremely slow.

    Last edited Jul 22, 2014 by selfservice0
  • Avatar of Mitsugaru Mitsugaru Jul 22, 2014 at 03:20 UTC - 0 likes

    @wiedzmin137: Go

    Have you done a null check on the player or sql objects?

    @selfservice0: Go

    My question is: what steps have you taken to determine that the library is at fault and not the specific implementation, Cauldron? Have you tested other plugins that utilize the library to have similar slow downs?

    @selfservice0: Go

    Appears to build fine for 1.7.10 without any code changes.

    Jenkins | Trello Dev board | Website
    Visit the Trello board to see/vote/comment on my current todo list for all projects in real time.
    Mine-RP Operator BFAK:52950,9c92ea09892ae7395af1f98741fb8dd73aed386e0b40f81435281ce5eca68c7f

  • Avatar of selfservice0 selfservice0 Jul 21, 2014 at 23:10 UTC - 0 likes

    If someone is willing/able to update this to work with 1.7.10 please message me I am more than willing to compensate for your hard.

    The github repositories is here: https://github.com/PatPeter/SQLibrary

  • Avatar of selfservice0 selfservice0 Jul 21, 2014 at 12:21 UTC - 0 likes

    this does not work properly with any of the cauldron 1.7.10 builds. Pulls sql data very slowly http://files.minecraftforge.net/Cauldron/

  • Avatar of wiedzmin137 wiedzmin137 Jul 07, 2014 at 14:57 UTC - 0 likes

    Hello. I have problem with NullPointerException at this line:

    ResultSet rs = sql.query("SELECT skill, level FROM skills WHERE name='" + player.getName().toLowerCase() + "';");

    Do you know what is reason of that error?

    ShadowKingdom - my server

    Classes & SkillTrees | Feudal land management | Community engagement systems

  • Avatar of SableDnah SableDnah May 25, 2014 at 22:58 UTC - 0 likes

    @Mitsugaru: Go

    Awesome, will do just that. thanks :)

    "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 Mitsugaru Mitsugaru May 25, 2014 at 21:50 UTC - 0 likes

    @SableDnah: Go

    Well, the best I can do is build a fork that should compile in Java 6 and host it on my Jenkins.

    Tell them to try the jar here and see if it works (haven't tested it).

    EDIT: Changed build to explicitly use OpenJDK 6, so, have them use at the latest build and hopefully that will work.

    Last edited May 25, 2014 by Mitsugaru: Update
  • Avatar of SableDnah SableDnah May 25, 2014 at 19:29 UTC - 0 likes

    @Mitsugaru: Go

    BTW sorry for the sudden influx of LegendQuest users - I didn't expect it to be so popular so fast!


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