@Override
public List<Productos_almacenes> getAllAlmacenes1BajoStock() throws Exception {
List<Productos_almacenes>productos_almacenes= new ArrayList();
Productos_almacenes producto_almacen= null;
try{
this.openConnection();
String sql = "SELECT `ID_almacen1`,COUNT(`ID_producto`),COUNT(`Stock`) FROM `productos-almacenes` WHERE `Stock`<5 group by `ID_almacen1`";
Statement stm = con.createStatement();
ResultSet rs= stm.executeQuery(sql);
while(rs.next()){
producto_almacen= new Productos_almacenes(
rs.getInt("ID_almacen1"),
rs.getInt("ID_producto"),
rs.getInt("Stock")
);
productos_almacenes.add(producto_almacen);
}
this.closeConnection();
} catch (Exception e) {
e.printStackTrace();
throw new Exception ("Error al recuperar la lista de almacenes, llame al CPD");
}
return productos_almacenes;
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try{
Productos_almacenesManager pam= new Productos_almacenesManager();
List<Productos_almacenes>productos_almacenes=pam.getAllAlmacenes1BajoStock();
request.setAttribute("productos_almacenes", productos_almacenes);
hacerForward("/listadoStock.jsp", request, response);
}catch(Exception e){
hacerForward("/error.jsp", request, response);
}
}
private void hacerForward(String target, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(target);
dispatcher.forward(request, response);
}
String sql = "SELECT `ID_almacen1`,`ID_producto`,`Stock` FROM `productos-almacenes` WHERE `Stock`<5 ORDER BY `ID_almacen1`";
String sql = "SELECT `ID_almacen1`,COUNT(`ID_producto`),COUNT(`Stock`) FROM `productos-almacenes` WHERE `Stock`<5 group by `ID_almacen1`";
@Override
public List<Productos_almacenes> getAllAlmacenes1BajoStock() throws Exception {
List<Productos_almacenes> productos_almacenes = new ArrayList();
Productos_almacenes producto_almacen = null;
try{
this.openConnection();
String sql = "SELECT `ID_almacen1`,COUNT(`ID_producto`) AS ID_producto,COUNT(`Stock`) AS Stock FROM `productos-almacenes` WHERE `Stock`<5 group by `ID_almacen1`";
Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery(sql);
while(rs.next()){
producto_almacen= new Productos_almacenes(rs.getInt("ID_almacen1"), rs.getInt("ID_producto"), rs.getInt("Stock"));
productos_almacenes.add(producto_almacen);
}
this.closeConnection();
} catch (Exception e) {
e.printStackTrace();
throw new Exception ("Error al recuperar la lista de almacenes, llame al CPD");
}
return productos_almacenes;
}