Añadir Menu Gestion de SAIS Gestion de baterias y gestion de personas
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.example.saipp.data
|
||||
|
||||
import android.util.Log
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.sql.Connection
|
||||
import java.sql.DriverManager
|
||||
import java.sql.SQLException
|
||||
@@ -34,4 +36,18 @@ object MariaDbConnection {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun testConnection(): Result<Unit> = withContext(Dispatchers.IO) {
|
||||
val connection = getConnection()
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close()
|
||||
Result.success(Unit)
|
||||
} catch (e: SQLException) {
|
||||
Result.failure(e)
|
||||
}
|
||||
} else {
|
||||
Result.failure(Exception("connection_failed"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user