diff options
| author | mjkwiatkowski <mati.rewa@gmail.com> | 2026-06-18 23:38:00 +0200 |
|---|---|---|
| committer | mjkwiatkowski <mati.rewa@gmail.com> | 2026-06-18 23:38:00 +0200 |
| commit | 54f94861da743cbd72d9755c2fbe4223176d90f4 (patch) | |
| tree | a4c2eddb01662e00a1c17514e9fb1218e8515efc /opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt | |
| parent | 4562f52c9b540944200b33d4ffbd60b3cbc5ee79 (diff) | |
feat: complete system redesign: KafkaComputeMonitor stays, SmartScheduler is working and only HTTPClient remains, the rest will be moved to Python scripts
Diffstat (limited to 'opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt')
| -rw-r--r-- | opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt b/opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt deleted file mode 100644 index 35d03feb..00000000 --- a/opendc-common/src/main/kotlin/org/opendc/common/utils/PostgresqlDB.kt +++ /dev/null @@ -1,52 +0,0 @@ -package org.opendc.common.utils - -import com.fasterxml.jackson.dataformat.toml.TomlMapper -import java.sql.Connection -import java.sql.DriverManager -import java.sql.SQLException -import java.util.Properties -/** - * Represents the Postgresql database. - * On setup cleans the entire database. - * - * @author Mateusz Kwiatkowski - * - * @see <a href=https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/DriverManager.html> - * https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/DriverManager.html</a> - */ -@Suppress("DEPRECATION") -public class PostgresqlDB { - private var properties = Properties() - private var connection : Connection? = null - - init { - try { - properties = TomlMapper().readerFor(Properties().javaClass) - .readValue(PostgresqlDB::class.java.getResource("/database.toml")) - connection = DriverManager.getConnection( - properties.getProperty("address").asJdbc(properties.getProperty("database")), - properties.getProperty("user"), - properties.getProperty("password")) - clear() - } catch (e: SQLException) { - print("${e.message}") - } - } - public fun clear(){ - val DELETE_ALL_TABLES = """ - DROP SCHEMA public CASCADE; - CREATE SCHEMA public; - """.trimIndent() - try { - val st = connection?.createStatement() - st?.executeQuery(DELETE_ALL_TABLES) - } catch (e: SQLException){ - println("${e.message}") - } - } - - private fun String.asJdbc(database : String) : String { - return "jdbc:postgresql://$this/$database" - } - -}
\ No newline at end of file |
