commit 11072025

This commit is contained in:
rdkartono
2025-07-11 09:34:12 +07:00
parent 2ee42da017
commit 474b03444e
9 changed files with 103 additions and 2 deletions

View File

@@ -1,9 +1,11 @@
import codes.Somecodes
import database.MariaDB
import org.tinylog.Logger
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
fun main() {
Logger.info("Application started" as Any)
val db = MariaDB()
db.close()
}

9
src/database/Log.kt Normal file
View File

@@ -0,0 +1,9 @@
package database
data class Log(
val index: ULong,
val datenya: String,
val timenya: String,
val machine: String,
val description : String
)

54
src/database/MariaDB.kt Normal file
View File

@@ -0,0 +1,54 @@
package database
import org.mariadb.jdbc.Connection
import org.tinylog.Logger
import java.sql.DriverManager
/**
* A class to manage a connection to a MariaDB database.
*
* @property address The address of the MariaDB server.
* @property port The port number of the MariaDB server.
* @property dbName The name of the database to connect to.
* @property username The username for the database connection.
* @property password The password for the database connection.
*/
class MariaDB (
address : String = "localhost",
port : Int = 3306,
dbName : String = "aas",
username : String = "admin",
password : String = "admin"
) {
private var connection : Connection? = null
var connected : Boolean = false
var SoundbankList : ArrayList<Soundbank> = ArrayList()
var MessagebankList : ArrayList<Messagebank> = ArrayList()
init {
try {
connection = DriverManager.getConnection("jdbc:mariadb://$address:$port/$dbName", username, password) as Connection
Logger.info("Connected to MariaDB" as Any)
connected = true
} catch (e : Exception) {
Logger.error("Failed to connect to MariaDB: ${e.message}" as Any)
}
}
/**
* Closes the MariaDB connection.
*/
fun close() {
try {
connection?.close()
Logger.info("Connection to MariaDB closed" as Any)
} catch (e : Exception) {
Logger.error("Error closing MariaDB connection: ${e.message}" as Any)
}
connected = false
}
}

View File

@@ -0,0 +1,11 @@
package database
data class Messagebank(
val index : UInt,
val Description: String,
val Language: String,
val ANN_ID : UInt,
val Voice_Type: String,
val Message_Detail: String,
val Message_TAGS: String
)

11
src/database/Soundbank.kt Normal file
View File

@@ -0,0 +1,11 @@
package database
data class Soundbank(
val index: UInt,
val Description: String,
val TAG : String,
val Category: String,
val Language: String,
val VoiceType: String,
val Path: String,
)