PreparedStatement stmt1 = con.prepareCall("update khol SET emailcnf = 'ya' where khol.id =
(SELECT guiid.id FROM guiid WHERE guiid.gchbi = 'htg1' and guiid.typ = 'reg')");
System.out.println("rows COUNT "+stmt1.executeUpdate());
stmt1.close();
输出是:
行COUNT 0
0由executeUpdate返回并且当我直接运行相同的语句在Mysql中它工作正常。
答案 0 :(得分:0)
您应该使用con.prepareStatement()
代替con.prepareCall()
请查看以下链接,以帮助您了解createStatement()
prepareSatement()
和prepareCall()
http://javaconceptoftheday.com/statement-vs-preparedstatement-vs-callablestatement-in-java/
以下内容应该有效:
PreparedStatement stmt1 = con.prepareStatement("update khol SET emailcnf = 'ya' where khol.id =
(SELECT guiid.id FROM guiid WHERE guiid.gchbi = 'htg1' and guiid.typ = 'reg')");
System.out.println("rows COUNT "+stmt1.executeUpdate());
stmt1.close();