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.
So I'm trying to figure out how to setup the data values. Can you please help me with that?
@Isalla
Have you made sure the plugin is on the server? and ill try and change the path.
I get an error on my Bukkit-Server with MySQLAPI_V1.7.9.jar Error: Cannot find main class `com.noliver92.cmg.api.mysql.MySQL
Why? The file path in the jar is "com.noliver92.cmg.api.mysq.MySQL" you forget the"l" in .mysql.
@ledship
Updated to 1.7.9 just now, staff should be processing it asap.
Does this work in 1.7.x?
@xDGaming
I am posting this on NoLiver92 (Nick)'s behalf to let you he we will not let you use the source code of MySQLAPI. We are also not going to release the source to the public on git, github etc. Just to let you guys know Nick will not be updating this/coding until he has finished university, therefore i will be updating this to the latest version soon, so stay tuned. Also i agree with @OlsonElliott; this could be exactly why you wanted the source to make a rival copy.
@xDGaming
I really doubt that NoLiver92 is going to give you access to his source code, mainly because if he gave you access then you could create a rival MySQL API, which it seems like you are planning on doing. I would advise you not to even start your project, if your goal is to take other authors source code and combining it and claiming it as your own.
I'm actually working on something called ExtremeAPI you don't mind me using your source code do you? It would help me out a lot!
Please add Update and Delete!
Can someone post their code of MySQL database replacing a hashmap?
Hey, can you please make an example with defined variables? I have problems with it and this will help me.
plugin.yml depend: [MySQLAPI] not [MySQLApi] :D
@Jannik8500
Have you included the jar in your plugin's build path/?
The constructor MySQLAPI(MySQL) is undefined
MySQLAPI api = new MySQLAPI((MySQL) Bukkit.getServer().getPluginManager().getPlugin("MySQLAPI"));
Please Help me!
Very nice work! I really hope you do continue to work on this.
Thanks! :D
This is a beautiful idea, good work!
@broseidon4
I am working as fast as i can and hope to have it done by the end of this week.
I am the only coder doing this plugin and i have to fit it around my full time job so my time is limited.
@NoLiver92
Any idea when this will be done? Also, it would be nice if you could make it so people could update the result set...
@broseidon4
This is the new update that i am working on and im trying to get it done as quick as i can. due to the nature of the mysql language when you update 1 column it changes the rest to null. The update will contain an update function and will mean you only specify what you want to change and it changes those values (the null values wont occur).
EDIT: Nevermind my mysql credentials were incorrect. I still have a question, is it possible to edit entries? Or can you only insert them?