mirror of
https://github.com/BlockWorldGroup/Ledger-Databases.git
synced 2025-10-14 21:00:01 +08:00
Added MariaDB support
This commit is contained in:
@@ -3,6 +3,7 @@ package net.quiltservertools.ledger.databases
|
||||
import net.quiltservertools.ledger.databases.databases.H2Database
|
||||
import net.quiltservertools.ledger.databases.databases.LedgerDatabase
|
||||
import net.quiltservertools.ledger.databases.databases.MySQL
|
||||
import net.quiltservertools.ledger.databases.databases.MariaDB
|
||||
import net.quiltservertools.ledger.databases.databases.PostgreSQL
|
||||
import net.quiltservertools.ledger.databases.databases.SQLite
|
||||
|
||||
@@ -11,5 +12,6 @@ enum class Databases(val database: LedgerDatabase) {
|
||||
MYSQL(MySQL),
|
||||
H2(H2Database),
|
||||
POSTGRESQL(PostgreSQL),
|
||||
SQLITE(SQLite)
|
||||
}
|
||||
SQLITE(SQLite),
|
||||
MARIADB(MariaDB)
|
||||
}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
package net.quiltservertools.ledger.databases.databases
|
||||
|
||||
import com.github.quiltservertools.ledger.Ledger
|
||||
import com.zaxxer.hikari.HikariConfig
|
||||
import com.zaxxer.hikari.HikariDataSource
|
||||
import net.quiltservertools.ledger.databases.DatabaseExtensionSpec
|
||||
import net.quiltservertools.ledger.databases.LedgerDatabases
|
||||
import java.nio.file.Path
|
||||
import javax.sql.DataSource
|
||||
|
||||
object MariaDB : LedgerDatabase {
|
||||
override fun getDataSource(savePath: Path): DataSource = HikariDataSource(HikariConfig().apply {
|
||||
jdbcUrl = "jdbc:mariadb://${Ledger.config[DatabaseExtensionSpec.url]}"
|
||||
username = Ledger.config[DatabaseExtensionSpec.userName]
|
||||
password = Ledger.config[DatabaseExtensionSpec.password]
|
||||
maximumPoolSize = Ledger.config[DatabaseExtensionSpec.maxPoolSize]
|
||||
connectionTimeout = Ledger.config[DatabaseExtensionSpec.connectionTimeout]
|
||||
addDataSourceProperty("rewriteBatchedStatements", "true")
|
||||
addDataSourceProperty("cachePrepStmts", true)
|
||||
addDataSourceProperty("prepStmtCacheSize", 250)
|
||||
addDataSourceProperty("prepStmtCacheSqlLimit", 2048)
|
||||
addDataSourceProperty("useServerPrepStmts", true)
|
||||
addDataSourceProperty("cacheCallableStmts", true)
|
||||
addDataSourceProperty("cacheResultSetMetadata", true)
|
||||
addDataSourceProperty("cacheServerConfiguration", true)
|
||||
addDataSourceProperty("useLocalSessionState", true)
|
||||
addDataSourceProperty("elideSetAutoCommits", true)
|
||||
addDataSourceProperty("alwaysSendSetIsolation", false)
|
||||
addDataSourceProperty("useJDBCCompliantTimezoneShift", true)
|
||||
addDataSourceProperty("useLegacyDatetimeCode", false)
|
||||
addDataSourceProperty("serverTimezone", "UTC")
|
||||
for ((key, value) in Ledger.config[DatabaseExtensionSpec.properties]) {
|
||||
addDataSourceProperty(key, value)
|
||||
}
|
||||
})
|
||||
|
||||
override fun getDatabaseIdentifier() = LedgerDatabases.identifier("mariadb")
|
||||
}
|
Reference in New Issue
Block a user