From d46d0d2890356c256a5ea9d6272718e9d0f47f49 Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 7 Oct 2018 01:56:42 +0200 Subject: [PATCH] big fix ORM getCustomResult --- .../java/fr/pandacube/java/util/orm/ORM.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/pandacube/java/util/orm/ORM.java b/src/main/java/fr/pandacube/java/util/orm/ORM.java index bfcd053..e309ee9 100644 --- a/src/main/java/fr/pandacube/java/util/orm/ORM.java +++ b/src/main/java/fr/pandacube/java/util/orm/ORM.java @@ -165,17 +165,19 @@ public final class ORM { public static ResultSet getCustomResult(String sql, List params) throws ORMException { try { - try (PreparedStatement ps = connection.getNativeConnection().prepareStatement(sql)) { - - int i = 1; - for (Object val : params) { - if (val instanceof Enum) val = ((Enum) val).name(); - ps.setObject(i++, val); - } - Log.debug(ps.toString()); - - return ps.executeQuery(); + PreparedStatement ps = connection.getNativeConnection().prepareStatement(sql); + int i = 1; + for (Object val : params) { + if (val instanceof Enum) val = ((Enum) val).name(); + ps.setObject(i++, val); } + Log.debug(ps.toString()); + + ResultSet rs = ps.executeQuery(); + + ps.closeOnCompletion(); + + return rs; } catch (SQLException e) { throw new ORMException(e); }