开发者

Java Prepared Statement within Oracle catsearch

I am facing problems binding the prepared statement argument within the catsearch clause. On execution I get java.sql.SQLException: Invalid column index I tried a few other methods, by escaping quotes(both single and double), but still running into SQL E开发者_如何学编程xceptions (Invalid column/Missing right parentheses) Appreciate if I could be pointed to the correct way of binding -

String sqlForcatString = SELECT * from EVENT_TABLE where catsearch(DATA,\' %?% within TAG\',null) stmt = conn.prepareStatement(sqlForCatString); stmt.setString(1,keyValue);


Your parameter is contained in a quoted string in the sql query and so it ist not recognizable by the sql parser. You should be able to use string concatenation inside the query to build this string instead:

String sqlForcatString = "SELECT * from EVENT_TABLE where catsearch(DATA,'<query> <textquery grammar=\"context\"> %' || ? || '% within TAG</textquery></query>',null)";
stmt = conn.prepareStatement(sqlForCatString);
stmt.setString(1,keyValue);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜