Bukkit and BungeeCord library for asynchronous execution of SQL queries
Are you tired of syncing results of asynchronously executed methods back to the server thread? Do you want to easily configure your connection pools? Then this library is for you!
All tasks you submit using this library are executed asynchronously. After a task completes (either normally or by throwing an exception), its callback method is executed in the server thread (Bukkit plugins) or in one of the plugin threads (Bungee plugins). This library uses HikariCP as the main connection pool. More information on GitHub .
This library is also available as a BungeeCord plugin .
Dependencies :
Example:
1. Create a repository by extending PluginSqlTaskSubmitter :
2. Use your repository:
Are you tired of syncing results of asynchronously executed methods back to the server thread? Do you want to easily configure your connection pools? Then this library is for you!
All tasks you submit using this library are executed asynchronously. After a task completes (either normally or by throwing an exception), its callback method is executed in the server thread (Bukkit plugins) or in one of the plugin threads (Bungee plugins). This library uses HikariCP as the main connection pool. More information on GitHub .
This library is also available as a BungeeCord plugin .
Dependencies :
Example:
1. Create a repository by extending PluginSqlTaskSubmitter :
Code (Java):
public
final
class UserRepository
extends PluginSqlTaskSubmitter
{
public UserRepository ( JavaPlugin plugin ) { super ( plugin ) ; }
public void getUser ( UUID uuid, BiConsumer < User, Throwable > callback ) {
String query = "SELECT * FROM `users` WHERE `uuid` = ?" ;
// you can submit different types of tasks
submitSqlPreparedStatementTask ( query, preparedStatement -> {
// executed asynchronously
preparedStatement. setString ( 1 , uuid. toString ( ) ) ;
ResultSet rs = preparedStatement. executeQuery ( ) ;
return rs. next ( )
? new User ( uuid, rs. getString ( "email" ) )
: null ;
} , callback ) ;
}
}
public UserRepository ( JavaPlugin plugin ) { super ( plugin ) ; }
public void getUser ( UUID uuid, BiConsumer < User, Throwable > callback ) {
String query = "SELECT * FROM `users` WHERE `uuid` = ?" ;
// you can submit different types of tasks
submitSqlPreparedStatementTask ( query, preparedStatement -> {
// executed asynchronously
preparedStatement. setString ( 1 , uuid. toString ( ) ) ;
ResultSet rs = preparedStatement. executeQuery ( ) ;
return rs. next ( )
? new User ( uuid, rs. getString ( "email" ) )
: null ;
} , callback ) ;
}
}
Code (Java):
final
class ExamplePlugin
extends JavaPlugin
{
private UserRepository userRepository ;
@Override
public void onEnable ( ) {
userRepository = new UserRepository ( this ) ;
userRepository. getUser ( UUID. fromString ( "..." ) , ( user, throwable ) -> {
// executed in the server-thread or a plugin-thread.
if ( throwable != null ) {
System . err . println ( "exception: " + throwable ) ;
} else {
System . out . println ( "result: " + user ) ;
}
} ) ;
}
}
private UserRepository userRepository ;
@Override
public void onEnable ( ) {
userRepository = new UserRepository ( this ) ;
userRepository. getUser ( UUID. fromString ( "..." ) , ( user, throwable ) -> {
// executed in the server-thread or a plugin-thread.
if ( throwable != null ) {
System . err . println ( "exception: " + throwable ) ;
} else {
System . out . println ( "result: " + user ) ;
}
} ) ;
}
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.7, 1.8, 1.9
- 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.
DatabaseLib is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 232 times (via Spigot). Download it and open it directly in the game.