【发布时间】:2009-06-23 10:26:58
【问题描述】:
代码摘录
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM sch.tab1 where col1 like lower ( 'ABZ' ) ");
preparedStatement.executeQuery();
以上代码执行成功。
但是当我尝试执行此操作时
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM sch.tab1 where col1 like lower ( ? ) ");
preparedStatement.setString ( myValue );
preparedStatement.executeQuery();
它引发异常。"要准备的字符串包含对参数标记的无效使用"
这可能是什么问题?
找到答案,查看 cmets
【问题讨论】:
-
这可能与 jdbc 驱动程序相关。你的数据库是什么?
-
鉴于标签,我假设是 db2。
-
我找到了答案。感谢保罗·切尔诺克。 -- SELECT * FROM sch.tab1 where col1 like lower ( '' || ? ) --
标签: java jdbc prepared-statement