【问题标题】:ORA-00933: SQL command not properly ended for UPDATE command [closed]ORA-00933: UPDATE 命令的 SQL 命令未正确结束 [关闭]
【发布时间】:2019-08-28 04:17:56
【问题描述】:

我的更新命令抛出异常

Class.forName("oracle.jdbc.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","Durga");
st = con.createStatement();
br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Bonus Amount : ");
int bonus_amt = Integer.parseInt(br.readLine());
System.out.println("salary range:");
float sal_range = Float.parseFloat(br.readLine());
int rowCount = st.executeUpdate("UPDATE employee SET esal = esal "+bonus_amt+ " where esal <" +sal_range);

【问题讨论】:

标签: java sql database oracle jdbc


【解决方案1】:

根据您的查询String"UPDATE employee SET esal = esal "+bonus_amt+ " where esal &lt;" +sal_range 我假设,您在set 关键字之后缺少一个运算符,如下所示:

"UPDATE employee SET esal = esal + " + bonus_amt + " where esal < " + sal_range

否则你会得到这样的查询:"UPDATE employee SET esal = esal 1 where esal &lt; 1"

P.S.:我忘了提一下,由于 sql 注入,自己编写查询 String 可能会很危险。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-09-09
    • 2010-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多