SQLSimpleAPI
For server administrator:
Just install the .jar in your plugin folder, there is nothing to configure
For developpers:
This API allow you to design class container (by using annotations) for data you want to store. You can then send the container through the DatabaseUtils of you choice (sqlite or MySQL)
It currently support the following SQL types :
- TEXT
- INTEGER
- DOUBLE
- VARCHAR
- BLOB (only MySQL)
Also supporting data length, PRIMARY KEY, NOT NULL and AUTO_INCREMENT
Here is a basic container definition :
@Row(tableName = "dbTable")
public static class DataContainer extends Request
{
@Value(fieldName = "value1", type = DataType.INTEGER)
public int value;
@Value(fieldName = "value2", type = DataType.TEXT)
public String text;
/*
* Where clause is used when retrieving data from the db
* Here id is a VARCHAR(15)
* You can set multiple Where clauses in a row, they will be added together to make a AND statement
*/
@Where(fieldName = "id", type = DataType.VARCHAR)
@Value(fieldName = "id", type = DataType.VARCHAR, infos = {KeyInfo.PRIMARY_KEY}, length = 15)
public String id;
@Override
public void postInsert(DatabaseUtils utils) throws WrongBaseClassException, DataRetrieveException {}
@Override
public void postUpdate(DatabaseUtils utils) throws WrongBaseClassException, DataRetrieveException {}
@Override
public void postRetrieve(DatabaseUtils utils) throws WrongBaseClassException, DataRetrieveException {}
}
And here is how you send it to the database :
public static void insertData() throws WrongBaseClassException, TableCreationException, DataInsertionException
{
DataContainer container = new DataContainer();
container.value = 12;
container.text = "myText";
container.id = "container1";
dbUtils.insertData(container);
}
public static void retrieveData() throws WrongBaseClassException, DataRetrieveException
{
DataContainer retriever = new DataContainer();
retriever.id = "container1";
retriever = dbUtils.retrieveData(retriever);
}
public static void deleteData() throws WrongBaseClassException, DataDeleteException
{
DataContainer deleter = new DataContainer();
deleter.id = "container1";
dbUtils.deleteData(deleter);
}
public static void main(String[] args) throws ConnectionException, WrongBaseClassException, TableCreationException, DataInsertionException, DataRetrieveException, DataDeleteException
{
dbUtils.connect();
dbUtils.createTable(DataContainer.class);
insertData();
retrieveData();
deleteData();
dbUtils.close();
}
You can find other usage example here -> https://gitlab.com/AtomixSoldier/SQLSimpleAPI/snippets
Also support database update, more SQL type support will come
Please report any bug in the comment section, I'm also open to any suggestion
You can also refer to the gitlab issues tracking -> https://gitlab.com/AtomixSoldier/SQLSimpleAPI/issues/
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta