Efficient way to Handle ResultSet in Java
I'm using a ResultSet in Java, and am not sure how to properly close it. I'm considering using the ResultSet to construct a HashMap and then closing the ResultSet after that. Is this HashMap technique efficient, or are there more efficient ways of handling this situation? I need both keys and values, so using a HashMap seemed like a logical choice. If using a HashMap is the most efficient method, how do I construct and use the HashMap in my code? Here's what I've tried: public HashMap resultSetToHashMap(ResultSet rs) throws SQLException { ResultSetMetaData md = rs.getMetaData(); int columns =