title: Convert Java resultset to String array
body: <p>I am writing a program that will query an MS access database, return the query as a result set, and then I want to ultimately convert that result set into a String array, so that I can pass it into the constructor of a Swing JComboBox - so the ComboBox will list the items returned by the query.</p>
  
  <p>I have been able to store the rows of the result set into an ArrayList, and then convert that ArrayList into an object array, and the combobox will list the correct items, but as objects. I simply cannot ever cast that ArrayList to a String array. Does anyone know if this is possible? Here is some of my code...</p>
  
  <pre><code>// Convert the Resultset into an array list
  
  public ArrayList&lt;ArrayList&lt;Object&gt;&gt; Results2Array(ResultSet rs) throws SQLException {
      ResultSetMetaData metaData = rs.getMetaData();
      int columns = metaData.getColumnCount();
  
      ArrayList&lt;ArrayList&lt;Object&gt;&gt; al = new ArrayList&lt;ArrayList&lt;Object&gt;&gt;();
  
      while (rs.next()) {
          ArrayList&lt;Object&gt; record = new ArrayList&lt;Object&gt;();
  
          for (int i = 1; i &lt;= columns; i++) {
              Object value = rs.getObject(i);
              record.add(value);
          }
          al.add(record);
      }
      return al;
  }
  
  // Convert ArrayList to Object Array, and pass into GUI
  
  ArrayList&lt;String&gt; Locations = new ArrayList&lt;String&gt;();
  ArrayList&lt;String&gt; Months = new ArrayList&lt;String&gt;();
  ArrayList&lt;String&gt; Years = new ArrayList&lt;String&gt;();
  
  try {
      DB.loadDriver();
      DB.makeConnection();
      DB.buildStatement();
  
      Locations = DB.getLocations();
      Months = DB.getMonths();
      Years = DB.getYears();
  
      Object[] arrLocations = Locations.toArray();
      Object[] arrMonths = Months.toArray();
      Object[] arrYears = Years.toArray();
  
      dbGUI ui = new dbGUI(arrLocations, arrMonths, arrYears);
      ui.setVisible(true);
  </code></pre>
  
  <p>Can anyone offer any suggestions?  Thanks!</p>
  
  <hr>
  
  <p>UPDATE:</p>
  
  <p>Here is the stack trace that I am receiving:</p>
  
  <pre><code>java.lang.ArrayStoreException
      at java.lang.System.arraycopy(Native Method)
      at java.util.Arrays.copyOf(Unknown Source)
      at java.util.ArrayList.toArray(Unknown Source)
      at kidsfirstdb.Main.main(Main.java:23)
  </code></pre>