My problem is this, I have a basic stock program. The stock manages items, these have id (int), name (string), price (float), category (string) the dilemma is at the time of updating because I update the price, the category but not the name! It's getting on my nerves, it does not even throw me a mistake from where to start investigating, if anyone can help, thank you.
here is the code of my articleDAO:
//solamente el metodo de actualizar articulo subi, si necestin mas revisen el github
public void actualizarArticulo(Articulo art) {
Conexion con = new Conexion();
try {
con.conectar();
//Esta consulta es para obtener y guardar el numero de id de la categoria del art
int idCat=0;
PreparedStatement st = con.getConnection().prepareStatement("select * from categorias where nombreCat=(?);");
st.setString(1, art.getCategoria());
ResultSet rs = st.executeQuery();
idCat=rs.getInt("idCat");
//Esta consulta es para actualizar el art
st = con.getConnection().prepareStatement("UPDATE articulos SET nombreArt=(?),precioArt=(?),categoriaArt=(?) WHERE idArt = (?);");
st.setString(1, art.getNombre());
st.setFloat(2, art.getPrecio());
st.setInt(3, idCat);
st.setInt(4, art.getId());
st.execute();
JOptionPane.showMessageDialog(null, "Se actualizo ");
} catch (SQLException e) {
e.printStackTrace();
e.getMessage();
}finally {
con.cerrar();
}
}
Any other class that they want to review, I leave the github: link
EDIT: probe using the method executeUpdate () and there was no change, I have no idea where to keep looking, create a new table and probe, it works correctly, but in this one I need not do it! also try to change the name to the field but it does not work either