Refactor template placeholders for repository name.

Updated rootProject.name and JDBC URL configuration to use template placeholders for better flexibility and consistency. Removed unused code and initialization block from Database.kt to improve readability and maintainability.
This commit is contained in:
2024-12-01 11:29:46 +01:00
parent 952c705ab3
commit 1f6dc536fb
3 changed files with 2 additions and 31 deletions

View File

@@ -1,5 +1,4 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}
//var REPO_NAME = "template"
rootProject.name = "${REPO_NAME}"
rootProject.name = "{{.RepoName}}"

View File

@@ -25,7 +25,7 @@ fun main() {
Class.forName("nl.astraeus.jdbc.Driver")
Database.initialize(HikariConfig().apply {
driverClassName = "nl.astraeus.jdbc.Driver"
jdbcUrl = "jdbc:stat:webServerPort=6001:jdbc:sqlite:data/${REPO_NAME}.db"
jdbcUrl = "jdbc:stat:webServerPort=6001:jdbc:sqlite:data/{{.RepoName}}.db"
username = "sa"
password = ""
maximumPoolSize = 25

View File

@@ -18,12 +18,6 @@ fun <T> transaction(
if (!hasConnection) {
currentConnection.set(Database.getConnection())
/*
} else if (scope == TxScope.REQUIRES_NEW) {
oldConnection = currentConnection.get()
currentConnection.set(Database.getConnection())
*/
}
val connection = currentConnection.get()
@@ -76,26 +70,4 @@ object Database {
ds?.close()
}
init {
val properties = Properties()
properties["journal_mode"] = "WAL"
val config = HikariConfig().apply {
driverClassName = "nl.astraeus.jdbc.Driver"
jdbcUrl = "jdbc:stat:webServerPort=6001:jdbc:sqlite:data/daw3.db"
username = "sa"
password = ""
maximumPoolSize = 25
isAutoCommit = false
dataSourceProperties = properties
validate()
}
config.addDataSourceProperty("cachePrepStmts", "true")
config.addDataSourceProperty("prepStmtCacheSize", "250")
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048")
ds = HikariDataSource(config)
}
}