- Compatible API Versions
- 1.X, 1.0.11, 1.0.12, 1.0.13, 1.0.14
- Sourcecode
- https://github.com/hteppl/DataManager
- Contributors
- hteppl, IWareQ
DataManager
	
	
		
		
	
	
		
			
		
		 
	
 
	
	
		
		
	
	
		
			
		
		 
	
DataManager is a simple library plugin for Nukkit Minecraft Bedrock core (and forks), that will help you to create and manage your SQL connections with ease.
Libraries
Sql2o is small useful framework that makes coding for database easy.
HikariCP is a "zero-overhead" production ready JDBC connection pool.
At roughly 130Kb, the library is very light.
Performance of SELECT
Execute 1000 SELECT statements against a DB and map the data returned to a POJO.
How to install
If any plugin requires a DataManager, you just need to download and put it in
Maven
	
	
	
		
	
	
	
		
Gradle
	
	
	
		
	
	
	
		
Configuration
Default plugin
	
	
	
		
How to use
Firstly we recommend to read:
Here is very basic example of your MySQL database class:
	
	
	
		
or SQLite database class:
	
	
	
		
After that, you can easily do what you want with your Sql2o connections:
	
	
	
		
					
					
	
					
					
					
					
				DataManager is a simple library plugin for Nukkit Minecraft Bedrock core (and forks), that will help you to create and manage your SQL connections with ease.
Libraries
Sql2o is small useful framework that makes coding for database easy.
HikariCP is a "zero-overhead" production ready JDBC connection pool.
At roughly 130Kb, the library is very light.
Performance of SELECT
Execute 1000 SELECT statements against a DB and map the data returned to a POJO.
| Method | Duration | 
| Hand coded ResultSet | 15ms | 
| Sql2o | 24ms (60% slower) | 
If any plugin requires a DataManager, you just need to download and put it in
plugins folder. Usually it will be enough. Also, you can configure some default database settings in config.yml.Maven
		XML:
	
	<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
		XML:
	
	<dependency>
    <groupId>com.github.hteppl</groupId>
    <artifactId>DataManager</artifactId>
    <version>2.1.0-SNAPSHOT</version>
</dependency>
		Code:
	
	allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}
		Code:
	
	dependencies {
    implementation 'com.github.hteppl:DataManager:2.1.0-SNAPSHOT'
}Configuration
Default plugin
config.yml settings.
		YAML:
	
	# sqlite path settings for method SQLiteDatabase(String database)
sqlite:
  # use global folder for saving sqlite tables (near plugins, worlds, etc.) or plugin folder
  global: true
  # name for folder if "global" is set to true
  folder-name: "database"
# mysql settings
mysql:
  # default mysql connection properties
  properties: "useSSL=false&autoReconnect=true&useUnicode=true&serverTimezone=UTC"
  # Hikari connection pool settings (https://github.com/brettwooldridge/HikariCP)
  hikari:
    auto-commit: true
    connection-timeout: 30000
    idle-timeout: 600000
    keepalive-time: 0
    max-lifetime: 1800000
    maximum-pool-size: 10Firstly we recommend to read:
Here is very basic example of your MySQL database class:
		Java:
	
	import me.hteppl.data.database.MySQLDatabase;
import org.sql2o.Connection;
public class MyDatabase extends MySQLDatabase {
    public MyDatabase() {
        super("host", "database", "user", "password");
        // also you can execute your db scheme with
        this.executeScheme("CREATE TABLE IF NOT EXISTS ...");
        // or use openConnection() method
        try (Connection connection = this.openConnection()) {
            connection.createQuery("SELECT ...").executeUpdate();
        }
        // if you need disable auto commit, use beginTransaction() method
        try (Connection connection = this.beginTransaction()) {
            connection.createQuery("SELECT ...").executeUpdate();
        }
    }
}
		Java:
	
	import me.hteppl.data.database.SQLiteDatabase;
import org.sql2o.Connection;
public class MyDatabase extends SQLiteDatabase {
    public MyDatabase() {
        super("database");
        // also you can execute your db scheme with
        this.executeScheme("CREATE TABLE IF NOT EXISTS ...");
        // or use openConnection() method
        try (Connection connection = this.openConnection()) {
            connection.createQuery("SELECT ...").executeUpdate();
        }
        // if you need disable auto commit, use beginTransaction() method
        try (Connection connection = this.beginTransaction()) {
            connection.createQuery("SELECT ...").executeUpdate();
        }
    }
}
		Java:
	
	/* import your database class */
public class Main {
    public static void main(String[] args) {
        MyDatabase db = new MyDatabase();
        try (Connection connection = db.openConnection()) {
            connection.createQuery("SELECT ...");
        }
        // also you can execute your db scheme with
        db.executeScheme("CREATE TABLE IF NOT EXISTS ...");
    }
} 
				
 
 
		