diff options
author | Simon Rettberg | 2017-12-18 14:37:45 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-18 14:37:45 +0100 |
commit | 1eb8d85b6817cb4114c8205b4ffcb050c9753de1 (patch) | |
tree | 03bbe1018ea62939078fe02328c2600285062afb /dozentenmodulserver | |
parent | [server] DbImage: Fix image not being marked as invalid (diff) | |
download | tutor-module-1eb8d85b6817cb4114c8205b4ffcb050c9753de1.tar.gz tutor-module-1eb8d85b6817cb4114c8205b4ffcb050c9753de1.tar.xz tutor-module-1eb8d85b6817cb4114c8205b4ffcb050c9753de1.zip |
[server] Add explicit close call to statement
Diffstat (limited to 'dozentenmodulserver')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOsVirt.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOsVirt.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOsVirt.java index a6491993..9c083efe 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOsVirt.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbOsVirt.java @@ -21,18 +21,21 @@ public class DbOsVirt { public static void storeOsList(List<OperatingSystem> list) throws SQLException { try (MysqlConnection connection = Database.getConnection()) { - MysqlStatement osGeneralStmt = connection.prepareStatement("INSERT INTO operatingsystem" - + " (osid, displayname, architecture, maxmem, maxcpu) VALUES" - + " (:osid, :displayname, :architecture, :maxmem, :maxcpu)" - + " ON DUPLICATE KEY UPDATE displayname = VALUES(displayname), architecture = VALUES(architecture)," - + " maxmem = VALUES(maxmem), maxcpu = VALUES(maxcpu)"); - for (OperatingSystem os : list) { - osGeneralStmt.setInt("osid", os.osId); - osGeneralStmt.setString("displayname", os.osName); - osGeneralStmt.setString("architecture", os.architecture); - osGeneralStmt.setInt("maxmem", os.maxMemMb); - osGeneralStmt.setInt("maxcpu", os.maxCores); - osGeneralStmt.executeUpdate(); + { + MysqlStatement osGeneralStmt = connection.prepareStatement("INSERT INTO operatingsystem" + + " (osid, displayname, architecture, maxmem, maxcpu) VALUES" + + " (:osid, :displayname, :architecture, :maxmem, :maxcpu)" + + " ON DUPLICATE KEY UPDATE displayname = VALUES(displayname), architecture = VALUES(architecture)," + + " maxmem = VALUES(maxmem), maxcpu = VALUES(maxcpu)"); + for (OperatingSystem os : list) { + osGeneralStmt.setInt("osid", os.osId); + osGeneralStmt.setString("displayname", os.osName); + osGeneralStmt.setString("architecture", os.architecture); + osGeneralStmt.setInt("maxmem", os.maxMemMb); + osGeneralStmt.setInt("maxcpu", os.maxCores); + osGeneralStmt.executeUpdate(); + } + osGeneralStmt.close(); } connection.commit(); MysqlStatement virtStmt = connection.prepareStatement("INSERT IGNORE INTO os_x_virt" |