简体   繁体   中英

oracle DELETE prepared statement

I need your help please! I have a problem at the level of the delete it goes very well at the console but at the level in the database no changes. Thanks for you help

public void b2_action() {
   try {
           String req ="DELETE from EMPLOYEES where 'FIRST_NAME' = (?)";
           conn = macon.getConnection();
           PreparedStatement ps = conn.prepareStatement(req);
           String a= text.getValue().toString();
           System.out.println(a);
           ps.setString(1,a);
           ps.executeUpdate();
           System.out.println("okkkkkkkkkkkkkkk");
       } catch (SQLException ex) {
           ex.printStackTrace();
       }
}

delete

console

The query must be:

String req ="DELETE from EMPLOYEES where FIRST_NAME = ?";

note the remotion of the single quotes... ' '

There are few mistakes in your query:

  • you don't need to put FIRST_NAME between quotes
  • you don't need parenthesis between your ?

String req = "DELETE from EMPLOYEES where FIRST_NAME = ?";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM