ACTUALIZAR CAMPOS BD
public boolean updateCategoria(ArrayList listaCat){
int id; String nombre = null, descripcion;
try {
Class.forName(DRIVER);
try (Connection cn = DriverManager.getConnection(URL, USERNAME, PASSWORD); Statement stmt = cn.createStatement()) {
Iterator it = listaCat.iterator();
while(it.hasNext()){
id = (Integer)it.next();
nombre = (String)it.next();
descripcion = (String)it.next();
stmt.executeUpdate("exec updateCategoria "+id+",'"+nombre.toUpperCase()+"', '"+descripcion+"'");
}
cn.close();
stmt.close();
}
JOptionPane.showMessageDialog(null,"Se ha actualizado correctamente la categoría: '"+nombre+"' en la base de datos","Information", JOptionPane.INFORMATION_MESSAGE);
return true;
} catch (ClassNotFoundException | SQLException e) {
JOptionPane.showMessageDialog(null, "Error en base de datos." +
"\n\nError recibido: "+e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
return false;
}
}
No hay comentarios:
Publicar un comentario