Not able to get ResultSet value into String array?
<pre><code>String query = "select email from emp_select";
Statement stmt;

try {

  DB db=new DB(); 
  db.connect();
  stmt = (Statement) db.conn.createStatement(); // DB is connected here              

  ResultSet rs = stmt.executeQuery(query);
  ResultSetMetaData rsmd = rs.getMetaData();

  int numberOfColumns = rsmd.getColumnCount();

  for (int i = 1; i &lt;= numberOfColumns; i++) {
    if (i &gt; 1)
        System.out.print(",  ");
  }
  System.out.println("");

  while (rs.next()) {
    for (int i = 1; i &lt;= numberOfColumns; i++) {
        if (i &gt; 1)
            System.out.print(",  ");

        String columnValue = rs.getString(i);
        name[i]=columnValue;
        System.out.println(name[i]);          //Everything executes well till here
    }
  }
  stmt.close();
} catch(Exception ex) {}

for (int i = 1; i &lt; name.length; i++) {
    System.out.println(name[i]);   // why it gives null value here ?
}
</code></pre>
