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:
MySQLAPIapi=newMySQLAPI((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:
<<code java>>
<<code java>>
<</code>> api.insertEntry("tablename", columnnames[], values[]); <</code>> 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
ResultSetres=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.