oracle DELETE准备好的声明

时间:2017-01-31 11:03:18

标签: java

我需要你的帮助!我在删除级别有一个问题它在控制台上非常好但在数据库中的级别没有变化。谢谢你的帮助

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

2 个答案:

答案 0 :(得分:2)

查询必须是:

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

请注意单引号的转移...... ' '

答案 1 :(得分:1)

错误很少  在您的查询中:

  • 您无需在引号之间加FIRST_NAME
  • 您的?
  • 之间不需要括号

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