CreeperSQL/DOCUMENT.MD
2026-01-14 16:31:58 +01:00

2.8 KiB

CreeperSQL

CreeperSQL is a standalone Java SQL library designed for Minecraft plugins.
It has no Bukkit/Spigot dependency, supports automatic configuration reading/creation, and provides simple SQL methods.


Features

  • Pure Java MySQL library
  • Automatic configuration file (plugins/MySQLConnection/config.yml) creation
  • Supports all standard SQL actions: SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, DROP TABLE
  • Config must be set or read before connecting
  • Simple, intuitive API for plugin developers
  • Can be used in any Minecraft plugin project

Installation

  1. Build the CreeperSQL JAR (see Build section).
  2. Import the JAR into your plugin project:
    • IntelliJ: File → Project Structure → Libraries → + → Java → select CreeperSQL.jar
  3. Add MySQL Connector/J to your project if not included in the JAR.

Usage

1. Set or read configuration

  • Option 1: Manual configuration

Set host, user, password, and database manually:

CreeperSQL mysql = new CreeperSQL();
mysql.setConfig("127.0.0.1:3306", "root", "password", "testdb");

  • Option 2: Read from config.yml

CreeperSQL mysql = new CreeperSQL();
mysql.readMinecraftConfig();

Note: Config must be fully filled out before connecting.


2. Connect to the database

mysql.connect();


3. Execute SQL actions

  • getTables() → returns a list of table names in the database
  • sqlAction(String sql) → executes any SQL query, returns a QueryResult object
  • createTable(String sql) → executes a CREATE TABLE statement
  • dropTable(String tableName) → drops the specified table
  • insert(String sql) → executes an INSERT statement
  • update(String sql) → executes an UPDATE statement
  • delete(String sql) → executes a DELETE statement
  • close() → closes the database connection

4. QueryResult Object

Returned by sqlAction():

  • rows → list of rows (each row is a list of strings)
  • affectedRows → number of rows affected by INSERT/UPDATE/DELETE
  • error → error message if SQL failed
  • hasError() → returns true if there was an error
  • hasRows() → returns true if the query returned rows

Build Instructions

  1. Open IntelliJ and create a Java project (SDK 17+ recommended)
  2. Add CreeperSQL.java to src
  3. Add MySQL Connector/J as a library
  4. Create a JAR artifact:
    • File → Project Structure → Artifacts → + → JAR → From modules with dependencies
  5. Build → Build Artifacts → Build
  6. The output JAR can now be imported into any Minecraft plugin project

Notes

  • Always call setConfig() or readMinecraftConfig() before connect()
  • The library is fully standalone and does not depend on Bukkit/Spigot
  • For heavy queries, run on an async thread to prevent server lag