title: Reading all rows from database and putting them into ArrayList - Java
body: <p>I've the below code,</p>
  
  <pre><code>ArrayList&lt;ArrayList&lt;String&gt;&gt; outer = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
  ArrayList&lt;String&gt; inner = new ArrayList&lt;String&gt;(); 
  ResultSet rs = statement.executeQuery(sqlQuery);
  ResultSetMetaData rsmd = rs.getMetaData();
  int columnsNumber = rsmd.getColumnCount();
  while (rs.next()) {
      for(int i=1; i&lt;=columnsNumber; i++){
          inner.add(rs.getString(i));
      }                   
  }
  outer.add(inner);
  return outer;
  </code></pre>
  
  <p>What I get for outer is something like this</p>
  
  <pre><code>[[100, 200, 300, 100, 200, 300]]
  </code></pre>
  
  <p>What I'm trying to get is</p>
  
  <pre><code>[[100, 200, 300], [100, 200, 300]]
  </code></pre>
  
  <p>I want each row to be an unique item in the list, but what I get is a list of all rows in one item in the list.</p>
  
  <p>How do I do it? </p>
  
  <p>Can someone help me out?</p>