|
|
@ -79,17 +79,23 @@ class SqliteManager(private val chunkmaster: Chunkmaster) {
|
|
|
|
fun executeStatement(sql: String, values: HashMap<Int, Any>, callback: ((ResultSet) -> Unit)?) {
|
|
|
|
fun executeStatement(sql: String, values: HashMap<Int, Any>, callback: ((ResultSet) -> Unit)?) {
|
|
|
|
val connection = getConnection()
|
|
|
|
val connection = getConnection()
|
|
|
|
if (connection != null) {
|
|
|
|
if (connection != null) {
|
|
|
|
val statement = connection.prepareStatement(sql)
|
|
|
|
try {
|
|
|
|
for (parameterValue in values) {
|
|
|
|
val statement = connection.prepareStatement(sql)
|
|
|
|
statement.setObject(parameterValue.key, parameterValue.value)
|
|
|
|
for (parameterValue in values) {
|
|
|
|
}
|
|
|
|
statement.setObject(parameterValue.key, parameterValue.value)
|
|
|
|
statement.execute()
|
|
|
|
}
|
|
|
|
val res = statement.resultSet
|
|
|
|
statement.execute()
|
|
|
|
if (callback != null) {
|
|
|
|
val res = statement.resultSet
|
|
|
|
callback(res)
|
|
|
|
if (callback != null) {
|
|
|
|
|
|
|
|
callback(res)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
statement.close()
|
|
|
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
|
|
|
chunkmaster.logger.severe("An error occured on sql $sql. ${e.message}")
|
|
|
|
|
|
|
|
chunkmaster.logger.info(ExceptionUtils.getStackTrace(e))
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
connection.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
statement.close()
|
|
|
|
|
|
|
|
connection.close()
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
chunkmaster.logger.severe("Could not execute sql $sql. No database connection established.")
|
|
|
|
chunkmaster.logger.severe("Could not execute sql $sql. No database connection established.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|