1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-22 16:56:16 +00:00

Fixed issue #94 by closing open statements

added out/ (IntelliJ) to .gitignore

Signed-off-by: Vest <Vest@users.noreply.github.com>
This commit is contained in:
Vest 2018-03-14 11:14:27 +01:00
parent 79b68bd93d
commit f3e226e43f
3 changed files with 9 additions and 4 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ dev/
todo
deploy.secret.sh
release_notes.txt
out/

View File

@ -278,11 +278,14 @@ class Database private constructor(var client: TelegramClient) {
try {
val rs = stmt!!.executeQuery(query)
rs.next()
return rs.getInt(1)
val result = rs.getInt(1)
rs.close()
return result
} catch (e: SQLException) {
throw RuntimeException("Could not get count of messages.")
}
}
@Synchronized

View File

@ -111,10 +111,10 @@ class DatabaseUpdates(protected var conn: Connection, protected var db: Database
logger.debug("No update necessary.")
}
stmt.close()
} catch (e: SQLException) {
throw RuntimeException(e)
}
}
private fun getUpdateToVersion(i: Int): DatabaseUpdate {
@ -145,7 +145,6 @@ internal abstract class DatabaseUpdate(protected var conn: Connection, protected
} catch (e: SQLException) {
throw RuntimeException(e)
}
}
@Throws(SQLException::class)
@ -155,6 +154,8 @@ internal abstract class DatabaseUpdate(protected var conn: Connection, protected
_doUpdate()
logger.debug("Saving current database version to the db")
stmt.executeUpdate("INSERT INTO database_versions (version) VALUES ($version)")
stmt.close()
}
@Throws(SQLException::class)