title: Most simple code to populate JTable from ResultSet
body: <p>I googled the whole day and no luck. I call <code>getnPrintAllData()</code> method after pressing OK button. So the code is:</p>
  
  <pre><code>public class DatabaseSQLiteConnection {
      Connection conn = null;
      PreparedStatement statement = null;
      ResultSet res = null;
  
      public DatabaseSQLiteConnection(){
          try{
              Class.forName("org.sqlite.JDBC");
              conn = DriverManager.getConnection("jdbc:sqlite:test.sqlite");
              statement = conn.prepareStatement("SELECT * from product_info;");
          }
          catch(Exception e){
              e.printStackTrace();
          }
      }   
  
      public void getnPrintAllData(){
          String name, supplier, id;
          DefaultTableModel dtm = new DefaultTableModel();
          Window gui = new Window(); //My JPanel class        
          try{
              res = statement.executeQuery();
              testResultSet(res);
              ResultSetMetaData meta = res.getMetaData();
              int numberOfColumns = meta.getColumnCount();
              while (res.next())
              {
                  Object [] rowData = new Object[numberOfColumns];
                  for (int i = 0; i &lt; rowData.length; ++i)
                  {
                      rowData[i] = res.getObject(i+1);
                  }
                  dtm.addRow(rowData);
              }
              gui.jTable1.setModel(dtm);
              dtm.fireTableDataChanged();
              //////////////////////////
  
          }
          catch(Exception e){
              System.err.println(e);
              e.printStackTrace();
          }
          finally{
              try{
                  res.close();
                  statement.close();
                  conn.close();
              }
              catch(Exception e){
                  e.printStackTrace();
              }
          }
      }    
  
      public void testResultSet(ResultSet res){
          try{
              while(res.next()){
                  System.out.println("Product ID: "+ res.getInt("product_id"));
                  System.out.println("Product name: "+ res.getString("product_name"));
                  System.out.println("Supplier: "+ res.getString("supplier"));
              }        
          }
          catch(Exception e){
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>My <code>testResultSet()</code> method is working properly.
  Now, how to change my code so that it works, or what is the most simple code to make <code>DefaultTableModel</code> from <code>ResultSet</code> ?
  Thanks in advance.</p>
  
  <p>Edit: I am reciving <code>java.lang.IllegalStateException: SQLite JDBC: inconsistent internal state</code> error.</p>