1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-23 01:06:17 +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 todo
deploy.secret.sh deploy.secret.sh
release_notes.txt release_notes.txt
out/

View File

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

View File

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