MySQL API
There has been an issue raised with this API - Currently you cannot update any entry in a table. you can use this for logging plugins as you can keep adding to the table but not update. I am working on this but as I am busy with a full time job its taking a bit of time to do. I will have an update out as soon as I can
MySQLAPI has been designed for programmers to who do not know MySQL statements to use a MySQL database with their plugin with easy use.
To use this API you have to put this Jar in the build path in your chosen developer program and make it a dependency in your plugin.yml file.
This is just the beginning of this API so any feedback would be good, and more features will be added on request to make this api better.
Example
Initialize The API:
MySQLAPI api = new MySQLAPI((MySQL) Bukkit.getServer().getPluginManager().getPlugin("MySQLAPI")); MySQLAPI.getInstance();
Connect To The Database:
api.Connect(DBHost, DBPort, DBDatabase, DBUser, DBPass);
This returns a boolean value. It returns true if it connected and false if there was a error. (common use send it to the logger to show status) Note - All fields are strings and the user MUST have permission to create, modify and delete tables!!
Creating a table:
api.createTable(TableName, ColumnNames[], dataTypes[]);
this creates the table if the table does not exist, if this is called and the table exists the code will be skipped causing no error. The ColumnNames and dataTypes are arrays. each value added to the arrays is another column. IMPORTANT - Make Sure That There Are The Same Number Of Entrys In Each Array Or The Plugin Might Crash the dataTypes array contains an option menu, see below for an example. These options are the data types for the database, you must have them! these have been chosen as they are interchangeable between the 2 languages.
typearray[0] = MySQLAPI.DataTypes.Text;
Another function is counting the number of rows in a table, this can be done like so and returns an integer:
api.countEntrys("tablename");
inserting an entry into the database table is as easy as:
api.insertEntry("tablename", columnnames[], values[]);
this function also takes the column names in an array with the values that are to be put into the database
To get every entry, this piece of code returns everything into a results set which you can get the information you need out of it
ResultSet res = api.getAllEntrys("tablename");
ResultSet res = api.getSortedEntrys(TableName, ColumnName, operator, SortValue); The same can be said for getting certain records:
the column name is the column that you want to search and the value is the criteria. The operator is an option again which contains the functions allowed, the format is like shown before.
Sorry theres been a bit of a delay in the update. I am adding a feature which requires a lot of work to make sure it works correctly and errors are not caused in the database. Thanks for the patience
@xMinecraft
I will sort this asap and upload the updated version withing the next day
And update action?