Using a HashMap to store database table & column names
<p>I have some code that retrieves table &amp; column names from a database:</p>

<pre><code>PreparedStatement p = conn.prepareStatement(
    "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'SQLUser'");
rs = p.executeQuery();
</code></pre>

<p>I was thinking that I could use a HashMap to store this data, where the key is the table name (which is always unique) and an ArrayList to store the list of columns contained within that table.</p>

<p>How can I iterate through the ResultSet so that for each table a new ArrayList is created, populated with related column names and then added to the HashMap using that table name as the key?</p>