private class CustomerRowMapper implements RowMapper<Customer>
{
    public Customer mapRow(ResultSet rs, int rowNum) throws SQLException
    {
        Customer cust = new Customer();

        cust.setCustomerID(rs.getInt("CustomerID"));
        cust.setEmail(rs.getString("Email"));
        cust.setName(rs.getString("Name"));
        cust.setPhone(rs.getString("Phone"));
        
        return cust;
    }
}            

		
@Autowired
public void setDataSource(DataSource ds)
{
    customerDataSource = ds;
    template = new JdbcTemplate(ds);
    mapper = new CustomerRowMapper();
}            
		

@Override
public List<Customer> allCustomers()
{
    List<Customer> customers = template
            .query("SELECT * FROM Customer", mapper);

    return customers;
}            


@Bean
public ServletRegistrationBean h2servletRegistration()
{
    ServletRegistrationBean registration = 
            new ServletRegistrationBean(
              new WebServlet());
    registration.addUrlMappings("/console/*");
    return registration;
}           


@RequestMapping(method = RequestMethod.GET)
public String allCustomers(Model model)
{
    List<Customer> custList = dao.allCustomers();
    if (custList != null)
    {
        model.addAttribute("customers", custList);
    }
    return "customers";
}            


<%@ taglib prefix="c" 
           uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>           
<html lang="en">
  <head>
    <title>Customer List</title>
    <link rel="stylesheet" href="/style.css"></link>
  </head>
  <body>
    <h1>Customer List</h1>
    <table>
      <tr>
        <th>Customer ID</th>
        <th>Name</th>
        <th>Phone</th>
        <th>Email</th>
      </tr>
      <c:forEach items="${customers}" var="cust">
        <tr>
          <td>${cust.customerID}</td>
          <td>${cust.name}</td>
          <td>${cust.phone}</td>
          <td>${cust.email}</td>
        </tr>
      </c:forEach>
    </table>
  </body>
</html>            




@RequestMapping(value = "/customer", method = RequestMethod.GET)
public @ResponseBody
List<Customer> getSegments()
{
    return dao.allCustomers();
}


<!DOCTYPE html>
<html>
  <head>
    <title>Customer List</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
    </script>
    <script src="scripts.js">
    </script>
    <link rel="stylesheet" href="/style.css"></link>
  </head>
  <body>
     <h1>Customer List</h1>
     <table id="custlist">
      <tr>
        <th>Customer ID</th>
        <th>Name</th>
        <th>Phone</th>
        <th>Email</th>
      </tr>
       
     </table>
  </body>
</html>


$(document).ready(function()
{
 $.getJSON("customer", function(theList)
 {
     for(var i = 0; i < theList.length; i++)
     {
         var row = 
             "<tr>" +
             "<td>" + theList[i].customerID + "</td>" +
             "<td>" + theList[i].name + "</td>" +
             "<td>" + theList[i].phone + "</td>" +
             "<td>" + theList[i].email + "</td>" +
             "</tr>";      
         
         $(custlist).append(row);
     }
 });        
});      


CREATE TABLE customer(customerID INT IDENTITY PRIMARY KEY, 
  name VARCHAR(100), phone VARCHAR(100), email VARCHAR(100));


INSERT INTO customer (name, phone, email) VALUES 
  ('Sam Smith', '555-1212', 'sam@sam.com');
INSERT INTO customer (name, phone, email) VALUES 
  ('Sue Jones', '555-1313', 'sue@sue.com');                    
INSERT INTO customer (name, phone, email) VALUES 
  ('Harry Wolfe', '555-1414', 'harry@wolfe.com');               


spring.datasource.url=jdbc:hsqldb:hsql://localhost/
spring.datasource.username=SA
spring.datasource.password=
spring.datasource.driver-class-name=org.hsqldb.jdbcDriver
