Commits

Anonymous committed 3ae60de

Patch from USER-67
Issue number:
Obtained from:
Submitted by:
Reviewed by:

Comments (0)

Files changed (1)

src/java/com/opensymphony/user/provider/jdbc/JDBCAccessProvider.java

  * DOCUMENT ME!
  *
  * @author $author$
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public class JDBCAccessProvider extends BaseJDBCProvider implements AccessProvider {
     //~ Static fields/initializers /////////////////////////////////////////////
                 handles = true;
             }
 
-            rs.close();
-            ps.close();
-
             // now try if the group exists
             if (handles == false) {
+              // close before reuse
+              rs.close();
+              ps.close();
+
                 ps = conn.prepareStatement("SELECT " + groupName + " FROM " + groupTable + " WHERE " + groupName + " = ?");
                 ps.setString(1, name);
                 rs = ps.executeQuery();
             ps = conn.prepareStatement("DELETE FROM " + membershipTable + " WHERE " + membershipGroupName + " = ?");
             ps.setString(1, name);
             ps.executeUpdate();
-            ps.close();
+            ps.close();  // close before reuse of handle
 
             ps = conn.prepareStatement("DELETE FROM " + groupTable + " WHERE " + groupName + " = ?");
             ps.setString(1, name);
                 removed = true;
             }
 
-            ps.close();
-            conn.close();
         } catch (SQLException e) {
             log.fatal("Could not remove group [" + name + "]", e);
         } finally {