比如在DbAuthorizationFactory.java中有: public Authorization createAuthorization(String username, String password) throws UnauthorizedException { if (username == null || password == null) { throw new UnauthorizedException(); } //Jive stores all passwords in hashed form. So, hash the plain text //password for comparison. password = StringUtils.hash(password); long userID = 0; Connection con = null; PreparedStatement pstmt = null; try { con = ConnectionManager.getConnection(); pstmt = con.prepareStatement(AUTHORIZE); pstmt.setString(1, username); pstmt.setString(2, password);
ResultSet rs = pstmt.executeQuery(); //If the query had no results, the username and password //did not match a user record. Therefore, throw an exception. if (!rs.next()) { throw new UnauthorizedException(); } userID = rs.getLong(1); } catch( SQLException sqle ) { System.err.println("Exception in DbAuthorizationFactory:" + sqle); sqle.printStackTrace(); throw new UnauthorizedException(); } finally { try { pstmt.close(); } catch (Exception e) { e.printStackTrace(); } try { con.close(); } catch (Exception e) { e.printStackTrace(); } } //Got this far, so the user must be authorized. return new DbAuthorization(userID); }
它没有关闭RESULTSET 这样可以吗?
|
|