【发布时间】:2023-04-08 04:06:01
【问题描述】:
尝试使用准备好的语句注入xmlexists函数的字符串参数时出错。
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Connection con = DriverManager.getConnection("jdbc:derby:c:\\mydb");
PreparedStatement st = con.prepareStatement("select * from \"Data\" where xmlexists(? passing by ref \"data\")");
st.setString(1, "//*[text()[contains(., 'v1')]]");
ResultSet rs = st.executeQuery();
错误:
ERROR 42Z75: XML 查询表达式必须是字符串文字。
在没有准备好的语句的情况下手动构建语句成功。
select *
from "Data"
where xmlexists('//*[text()[contains(., ''v1'')]]' passing by ref "data")
可能是什么原因?
【问题讨论】:
标签: java jdbc prepared-statement derby