title: Reading Data From Database and storing in Array List object
body: <p>Hello all i want to display entire content  of my database table on html page.I am trying    to fetch record from database first and store in <code>ArrayList</code> but when i return array list on html page it display only last record repeatedly as count of my database table.
  Here is the code below :             </p>
  
  <pre><code>public ArrayList&lt;CustomerDTO&gt; getAllCustomers() 
  {
      ArrayList&lt;CustomerDTO&gt; customers = new ArrayList&lt;CustomerDTO&gt;();
      CustomerDTO customer = null;
      Connection c;
      try {
          c = openConnection();
          Statement statement = c.createStatement();
          String s = "SELECT * FROM customer";
  
          ResultSet rs = statement.executeQuery(s);
          int g =0;
  
          while (rs.next()) {
  
              customer.setId(rs.getInt("id"));
              customer.setName(rs.getString("name"));
  
              customer.setAddress(rs.getString("address"));
              customer.setPhone(rs.getString("phone"));
              customer.setEmail(rs.getString("email"));
              customer.setBountPoints(rs.getInt("bonuspoint"));
              customer.setTotalsale(rs.getInt("totalsale"));
  
              customers.add(customer);
          }
  
          rs.close();
      } catch (Exception e) {
          System.out.println(e);
      }
  
      return customers;
  }
  </code></pre>