MySQL API 1.0.2

Easy MySQL connector - queries - updating - retrieving

  1. PauLeK
    Contributors:
    N/A
    MySQL API - version 1.0.1:
    This Plugin/API provides a really clean and fast code with connecting your plugins to an SQL database, you can easily manage an entire system using this API.

    In order for you to be able to use this API, you must place this API in your plugins folder and also add a dependency of this plugin to any plugin that you wish developing using this API.

    Adding a dependency is simply done in the plugin.yml - An example:


    The code below shows you how to exactly instantiate a new database connection and how to manipulate it as well in your plugin.

    Code (Java):

    public class Plugin extends JavaPlugin {

        private PluginDescriptionFile pdf;
       
        public String HOST = "";
        public String DATABASE = "";
        public String USER = "";
        public String PASS = "";
       
        public MySQL SQL;
       
        public boolean connected;
       
        @Override
        public void onEnable() {
            this.pdf = this.getDescription();
           
            this.SQL = new MySQL((Main) Bukkit.getServer().getPluginManager().getPlugin("MySQL"), pdf.getName());
            this.connected = SQL.Connect(HOST, DATABASE, USER, PASS);
           
            if(!this.connected) {
                this.getLogger().info("Unable to establish a MySQL connection.");
            }
        }
       
        @Override
        public void onDisable() {
           
        }
    }

     
    Examples of sending updates/queries:
    Code (Java):

    this.SQL.update(String.format("UPDATE `player_data` SET `money` = %d, `level` = %d WHERE `UUID` = '%s'",
                                    money, level, player.getUniqueID()));

    // Sending a query and retrieving a resultset
    final ResultSet rs = Plugin.SQL.query("SELECT * FROM `homes` LIMIT 500");
    try
    {
        while(rs.next())
        {
                   
        }
    }
    catch (SQLException e)
    {
        this.getLogger().info("Error executing a query: " + e.getErrorCode());
    }

     
    xBACONATORx and xCyberSkillz like this.

Recent Updates

  1. Security update - added a new function

Recent Reviews

  1. CROB
    CROB
    5/5,
    Version: 1.0.2
    i give this plugin a thumbsup now some of my other plugins that needs MySql is working thanks.
  2. WouterRamply
    WouterRamply
    5/5,
    Version: 1.0.2
    Hello, I hope you read this because I have a problem / question. I have a practice server but the plugin I use for this requires a database to allow some functions to work, I only do not understand it. :( Could you help me?
  3. Velerium
    Velerium
    5/5,
    Version: 1.0.1
    What i was looking for! Now i can easily develop with mySQL! But how fast and secure is that? Although nice resource!
    1. PauLeK
      Author's Response
      Not sure about speed though security should be fine, i'll be adding some more features and security to this API very soon. Pretty certain that the speed is fine, I tested it out myself with retrieving over a 100k columns and it merely took 2 seconds.