I want to ask a question that is difficult to formulate, to apologize in advance. When I am going to perform the PreparedStatement I check if the variable is NULL or it is empty with the textNoNULL () method, if the text is empty, as is the case with the IBAN variable, I want you to omit the action, but as in the statement you are waiting for a value "iba =?" I miss an error, I would like to be able to perform this action without error, that I sent a value that does not erase what the Database contains by an empty field or a NULL.
public void actualizarCuentaBancaria(){
private String iban = "";
private String entidad = 9012;
private String sucursal= 0415;
try {
String sentencia = "UPDATE cuenta_bancaria SET iban= ?, entidad= ?, sucursal= ? WHERE id_persona = ?";
PreparedStatement pst = getConnection().prepareStatement(sentencia);
if(textoNoNULL(iban)) pst.setString(1, iban); else //AQUI
if(textoNoNULL(entidad)) pst.setString(2, entidad);
if(textoNoNULL(sucursal)) pst.setString(3, sucursal);
pst.setInt(6, idPersona);
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
}
}
private boolean textoNoNULL(String palabra){
if(palabra == null || palabra.length() == 0)
return false;
else
return true;
}