Bukkit database API

Discussion in 'Bukkit Help' started by vogt31337, Jun 29, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    vogt31337

    Hi,

    I'm new to bukkit and the whole thing, I've just started an new server last monday and just recently switched over to bukkit. So go easy on me ;)

    I'm somewhat curious because while installing bukkit, I found bukkit.yml which stated a possibilty for a MySQL database; so I've setted one up. And somewhere I've heard you'll need the jail MySql.jar for bukkit. Everything setted up. Now my question:

    I've searched the sources of bukkit, grabbed through the forum and looked for examples. But none found. Is a database API builtin in bukkit? Is it planned?

    Because many plugins use their own databases or flat files (yuck!, MySQL is way faster IMHO). So a centralised access api would probably speed things up and give more compatibilty. Also you don't need to maintain so many tables =/ (or am I complety wrong?!?)

    greetz by Newbie
    ps.: Great work everyone! There are so many plugins, I'd love to try! Please keep up working on it.

    Okay just found a plugin, which uses bukkit internal database:
    http://forums.bukkit.org/threads/ad...easy-and-flexible-redeemable-codes-860.18286/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
  2. Offline

    Wulfspider

    MySQL and Persistence ("bukkit internal database") lib jar files are built into the latest builds of CraftBukkit. Downloading them yourself is not necessary.

    I believe the only thing that bukkit would store in the MySQL database if setup would be the player data and settings, but I am unsure as I haven't used it or looked into it much.

    The reason some plugins are using flat files is because they either don't have much experience with other storage conventions such as Persistence or SQLite or they don't see a need for it as they may not store much of anything in their flat files.

    It would be a mess if plugins tried to share tables... I could see data getting lost and poorly written plugins messing up tables due to typos or mistakes.
     
  3. Offline

    vogt31337

    for simple configurstions, agreed!

    As far as I overlook it's a quite complex thing. It's using EbeanServer: http://www.avaje.org/static/javadoc/pub/com/avaje/ebean/EbeanServer.html

    youll get it with a Bukkitplugin.getdatabase() and you can do some seriuos stuff with it. I'm not that experienced with ebeans, but until now it looks more like a search, modify, save system.

    saving entrys to database:
    Code:
    plugin.getDatabase().save(redeemCode);
    finding entrys in databse:
    Code:
    RedeemCode code = plugin.getDatabase().find(RedeemCode.class).where().ieq("code_name", codeName).findUnique();
    (samples are taken from Hidendra)
    Also it seems possible to query sql commands.

    Jeah I fear this kind of mess too. Crashed tables are a horror. My hope is writing a good article about using the database api will prevent messy code and crashed tables, maybe somekind of template. Also every plugin has a name field, I suggest attaching databse querys to this plugin name field. So different plugins won't mess up your tables (only their own tables).
     
  4. Offline

    Pocketkid2

    Is there an explanation of what the lines of code you showed mean? I don't really understand what the lines do, so I am worried I will do something wrong...Also showing the correct way to, again, as you said, search, modify, save. I am unfamiliar with that kind of thing.
     
Thread Status:
Not open for further replies.

Share This Page