in application-workloads/jenkins/jenkins-cicd-webapp/src/main/java/com/cvz/azure/DbAccess.java [11:45]
public ArrayList<Product> getProducts() throws Exception {
Connection conn = getConnection();
initDbIfNeed(conn);
// Perform some SQL queries over the connection.
try
{
Statement stmt = conn.createStatement();
String sql = "SELECT * FROM products";
ResultSet rs = stmt.executeQuery(sql);
ArrayList<Product> products= new ArrayList<Product>();
while (rs.next()) {
Product p = new Product();
p.Id = rs.getInt(1);
p.Title = rs.getString(2);
p.Category = rs.getString(3);
p.Description = rs.getString(4);
products.add(p);
}
rs.close();
stmt.close();
conn.close();
return products;
}
catch (SQLException e)
{
throw new SQLException("Encountered an error when executing given sql statement.", e);
}
}