Can not issue data manipulation statements with executeQuery()的解决方案

 Can not issue data manipulation statements with executeQuery() 报错的解决方案:
把“ResultSet rs = statement.executeQuery(sql);”改成“boolean rs = statement.execute(sql);”就不会报错了。
原因是查询sql是把查询的结果都打印出来,修改更新(update)只需要判断是否执行成功,不需要打印结果,
所以这里不能用executeQuery()方法。

上面打印的结果显示false,查看数据库的值已经被修改了。把“ statement.execute(sql)”改成

“ statement.executeUpdate(sql);”就可以啦~

猜你喜欢

转载自www.cnblogs.com/changpuyi/p/10427963.html
今日推荐