From ed6ecaeb2e226b7ddb553c8f00941f82af5de0f2 Mon Sep 17 00:00:00 2001 From: mdb Date: Sat, 26 May 2001 07:09:38 +0000 Subject: [PATCH] Close our JDBC statement when we're done with it. git-svn-id: https://samskivert.googlecode.com/svn/trunk@123 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../servlet/user/UserRepository.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java b/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java index 4ff6b7f8..fe4c217b 100644 --- a/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java +++ b/projects/samskivert/src/java/com/samskivert/servlet/user/UserRepository.java @@ -1,5 +1,5 @@ // -// $Id: UserRepository.java,v 1.8 2001/05/26 04:37:35 mdb Exp $ +// $Id: UserRepository.java,v 1.9 2001/05/26 07:09:38 mdb Exp $ package com.samskivert.servlet.user; @@ -299,14 +299,20 @@ public class UserRepository extends MySQLRepository // do the query IntMap map = new IntMap(); Statement stmt = _session.connection.createStatement(); - ResultSet rs = stmt.executeQuery("select userid, " + column + - " from users " + - "where userid in (" + ids + ")"); - while (rs.next()) { - int userid = rs.getInt(1); - String name = rs.getString(2); - map.put(userid, name); - } + try { + String query = "select userid, " + column + + " from users " + + "where userid in (" + ids + ")"; + ResultSet rs = stmt.executeQuery(query); + while (rs.next()) { + int userid = rs.getInt(1); + String name = rs.getString(2); + map.put(userid, name); + } + + } finally { + stmt.close(); + } // finally construct our result String[] result = new String[userids.length];