title: Convert SQL Query result into array of strings
body: <p>I am making queries to a SQLite3 database in Java using the SQLiteJDBC (Java JDBC driver for SQLite).</p>
  
  <p><em>If I make the SQL query <strong>SELECT name, pass FROM loginTable WHERE name='%s';</strong> is there a function to Return OR Convert the name &amp; pass strings returned from the query into a String array or ArrayList?</em></p>
  
  <p>The following code attempts to put the queries return into an array list but it fails, I know that the SQL database is fine &amp; the query I make because when I do this in command line it works.</p>
  
  <pre><code>ArrayList &lt;String&gt; result = new ArrayList&lt;String&gt;();
  ResultSet rs = stat.executeQuery( "SELECT ..." );
  
  for (int i=0; rs.next(); i++)
  {
     result.add( rs.getString(i) );
  }
  </code></pre>
  
  <p>It fails because the table loginTable has the columns: Index, name, pass. So looking at above, when i=0, &amp; I go rs.getString(0), it tries to get the string in the Index column.  </p>
  
  <p>The error output is</p>
  
  <blockquote>
    <p>java.sql.SQLException: column 0 out of bounds [1,1]</p>
  </blockquote>
  
  <p><strong>Does anyone know how I can put all results from an SQL query(ResultSet object) in an ArrayList or array?</strong></p>