title: How to retrieve result set of a query from MySQL in java
body: <p>I am already connected to my database:</p>
  
  <pre><code>Connection con = DriverManager.getConnection(
      "jdbc:mysql://instance23389.db.xeround.com:15296/Inventory","user","password");
  PreparedStatement Statement = con.prepareStatement("Select * from inventory");
  ResultSet result = Statement.executeQuery();
  while(result.next()) {
      //What to put here?
  }
  </code></pre>
  
  <p>This is the arraylist I want stored in that database:</p>
  
  <pre><code>static ArrayList&lt;Product&gt; Chart=new ArrayList&lt;Product&gt;();
  </code></pre>
  
  <p>And that has these objects stored in the arraylist:</p>
  
  <pre><code>double Total;
  String name;
  double quantity;
  String unit;
  double ProductPrice;
  </code></pre>
  
  <p>What is the general code I need to use to get the arraylist to be stored in the MySQL database?
  What is the general code I need to use to get the arraylist out of the MySQL database?</p>