mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2024-11-21 23:23:47 +00:00
remove redundant things from database config
This commit is contained in:
parent
27fd0607cc
commit
52ceb01d3a
@ -12,29 +12,15 @@ data class DatabaseConfig(
|
||||
val url: String = "jdbc:sqlite:file:test?mode=memory&cache=shared",
|
||||
val driver: String = JDBC::class.qualifiedName!!,
|
||||
val username: String = "",
|
||||
val password: String = "",
|
||||
val initAutomatically: Boolean = true
|
||||
val password: String = ""
|
||||
) {
|
||||
@Transient
|
||||
private lateinit var _database: Database
|
||||
val database: Database
|
||||
get() = try {
|
||||
_database
|
||||
} catch (e: UninitializedPropertyAccessException) {
|
||||
Database.connect(
|
||||
val database: Database = Database.connect(
|
||||
url,
|
||||
driver,
|
||||
username,
|
||||
password
|
||||
).also {
|
||||
_database = it
|
||||
it.transactionManager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE // Or Connection.TRANSACTION_READ_UNCOMMITTED
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
if (initAutomatically) {
|
||||
database // init database
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user