Util Dillan's MySQL(ite) API

Discussion in 'Resources' started by MCMatters, Jul 27, 2015.

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


    Dillan's MySQL(ite) API
    This is a MySQL and SQLite API.

    How to Use:

    1. Add all the files to your GitHub Project.
    2. Use the API!

    3. Put the following in your main class:
    NOTE: If you are using SQLite just leave the values like they are.​
    MySQL sql = new MySQL("host.name", "port", "database", "user", "pass");

    sql.openLite(plugin, dbpath);


    Retrieving Values (JavaDocs)
    ResultSet res = sql.query("SELECT * FROM users WHERE player='MCMatters'");
        res.getString("player"); //Read the JavaDocs

    Setting Information
    sql.update("INSERT INTO players (`PlayerName`, `tokens`) VALUES ('MCMatters', '0');");

    Prepared Statements
    MySQLPrepared msp = sql.prepare("SELECT * FROM users WHERE player=? AND tokens=?");
    //First arg is index and Second arg is the value.
    msp.setString(1, "PlayerName");
    msp.setInt(2, 1);
    //There is also msp.setObject(index, new Object());


    If you need help just comment down below!

    Last edited: Jul 27, 2015
  2. KingFaris11 and leet4044 like this.
  3. Offline


    @Assist Mine has a class for PreparedStatements and his is basically an api to connect to MySQL, mine has executeQuery/Update, Mine also doesn't have the unnecessary Class.forName that they put.
  4. Offline


    No offence, but I don't understand all the MySQL Utils. It's not that hard to do it yourself (and if you know what you're doing you can make it even faster, possibly more secure and/or more convenient for you) - Not directed at you necessarily, but yeah.
    Other than that, this is all right I guess.
  5. Pretty sure Class.forName is sometimes necessary to load the drivers, according to Stackoverflow.

    This allows us to easily use the database management API built into Java... As you can see in the thread, the Statement class has the methods: execute, executeUpdate and executeQuery.

    Also, there's a class called PreparedStatement, and you can use: connection.prepareStatement.

    I honestly see absolutely no reason as to why not use that instead of this.
  6. Offline


    @KingFaris11 bukkit already loads the drivers and my PreparedStatement class is just a simpler way of PreparedStatements.
  7. Ah right, didn't know it didn't. I still won't be using this, and probably many others, as PreparedStatement class already built in has all that I need, and is still as easy to use.
  8. Offline


Thread Status:
Not open for further replies.

Share This Page