ModsJava
MySQL API
Minecraft Java mod. Downloads from the MC Java Mods app on Android.
⬇ Download on Spigot
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:
name: Test
main: Test
author: Test
description: Test
version: 1.0.1
depend: [MySQL]Click to expand...
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 ( ) {
}
}
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 ( ) ) ;
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
MySQL API is a free Minecraft Java mod. Downloaded 8,730 times (via Spigot). Download it and open it directly in the game.