title: "SQLite JDBC: inconsistent internal state" when attempting to getColumnCount from ResultSetMetaData
body: <p>As the title would suggest I'm attempting to retrieve a Table Model from a result set of data. I'm still in the process of learning how to use Databases so I'm currently using this code:
  </p>
  
  <pre><code>import java.sql.ResultSet;
  import java.sql.ResultSetMetaData;
  
  import java.util.Vector;
  
  import javax.swing.table.DefaultTableModel;
  import javax.swing.table.TableModel;
  
  
  public class DbUtils {
      public static TableModel resultSetToTableModel(ResultSet rs) {
          try {
              ResultSetMetaData metaData = rs.getMetaData();
              int numberOfColumns = metaData.getColumnCount();
              Vector columnNames = new Vector();
  
              // Get the column names
              for (int column = 0; column &lt; numberOfColumns; column++) {
                  columnNames.addElement(metaData.getColumnLabel(column + 1));
              }
  
              // Get all rows.
              Vector rows = new Vector();
              while (rs.next()) {
                  Vector newRow = new Vector();
  
                  for (int i = 1; i &lt;= numberOfColumns; i++) {
                      newRow.addElement(rs.getObject(i));
                  }
  
                  rows.addElement(newRow);
              }
  
              return new DefaultTableModel(rows, columnNames);
          } catch (Exception e) {
              e.printStackTrace();
  
              return null;
          }
      }
  }
  </code></pre>
  
  <p>But pretty much the issue I'm having now is whenever the program reaches the line to retrieve the Column Count it gives me the "Inconsistent Internal State" error. Full list here:</p>
  
  <pre><code>java.lang.IllegalStateException: SQLite JDBC: inconsistent internal state
  at org.sqlite.core.CoreResultSet.checkCol(CoreResultSet.java:81)
  at org.sqlite.jdbc3.JDBC3ResultSet.getColumnCount(JDBC3ResultSet.java:699)
  at DbUtils.resultSetToTableModel(DbUtils.java:14)
  at Window.main(Window.java:170)
  </code></pre>
  
  <p>I've checked out the only other question related to this on stack overflow but got no insight from that one. Is there anything I can do?</p>
  
  <p>Thanks!</p>