Package net.blockhost.commons.database.core
@NullMarked
package net.blockhost.commons.database.core
Core database utilities for 6b6t plugins.
This package provides dialect-independent database connectivity using HikariCP connection pooling. It provides a unified API for connection management that works with any SQL database.
Quick Start with SQLManager (Recommended)
Use the database-specific modules (commons-database-mariadb, commons-database-postgres) for configuration that provides the JDBC URL and driver class:
// Using MariaDbConfig from commons-database-mariadb
MariaDbConfig dbConfig = config.database();
SQLManager sqlManager = SQLManager.create(dbConfig)
.poolName("MyPlugin-Pool")
.logger(plugin.getLogger())
.build();
sqlManager.registerTable("CREATE TABLE IF NOT EXISTS players (...)");
sqlManager.connect();
sqlManager.withConnection(connection -> {
// Use connection
});
sqlManager.shutdown();
Database-Specific Modules
For database-specific configuration, use the specialized modules:
commons-database-mariadb- MariaDB/MySQL configurationcommons-database-postgres- PostgreSQL configurationcommons-database-redis- Redis connectivity
- See Also:
-
ClassDescriptionImmutable holder for database connection credentials and configuration.Custom builder with validation.Builder for creating HikariCP connection pool data sources.Interface for database configurations that support HikariCP connection pooling.Generic SQL connection manager with HikariCP connection pooling.Builder for creating SQLManager instances.Functional interface for connection consumers that may throw SQLException.Functional interface for connection functions that may throw SQLException.