UPDATE oracle in java

0

I have a problem with an UPDATE in java, this one receives a parameter, it does not run, my syntax will put it here, maybe there is something that I forget, from what I've seen on the net, it's fine but I do not know pass: c

public void CollectRv(String Bcode){
      try{
    ConexionOracle conexionOracle = new ConexionOracle();
    conexionOracle.conectar();
    Connection conn = conexionOracle.getConnection();
    PreparedStatement ps = conn.prepareStatement("UPDATE tabla\n" +
                    "set tabla.estado = 1 \n" +
                    "where tabla.task_class_cd = 'CHECK' \n" +
                    "and tabla.estado = 0 \n" +
                    "and num = 3002000 \n" +
                    "and sched= (select sched from tabla where num =3002000 and code= ?");
    ps.setString(1,Bcode.trim());
    ps.executeUpdate();
    ps.close();
    conn.close();
    conexionOracle.cerrar();
     }catch (SQLException ex) {
        Logger.getLogger(Consulta.class.getName()).log(Level.SEVERE, null, ex);

    }
}
    
asked by elsa 25.05.2016 в 17:50
source

1 answer

1

I put the query in a variable of type String and execute it in this way and it works:

PreparedStatement ps = conn.prepareStatement(sql); 
                   ps.setString(1,Bcode.trim());
                   ps.executeUpdate();
                   ps.close(); 
                   conn.close(); 
                   conexionOracle.cerrar();
    
answered by 18.10.2016 в 20:29