LIKE语句中包含变量的SQL:列索引无效
我在用甲骨文LIKE语句中包含变量的SQL:列索引无效,sql,oracle,variables,sql-like,setstring,Sql,Oracle,Variables,Sql Like,Setstring,我在用甲骨文 PreparedStatement pstmt = con.prepareStatement("SELECT * FROM BookLoanInfo WHERE title LIKE '%?%' ORDER BY bid"); ResultSet rs; String bookstring = scan.nextLine(); try{ pstmt.clearParameters(); pstmt.setString(1, bookstring); rs =
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM BookLoanInfo WHERE title LIKE '%?%' ORDER BY bid");
ResultSet rs;
String bookstring = scan.nextLine();
try{
pstmt.clearParameters();
pstmt.setString(1, bookstring);
rs = pstmt.executeQuery();
实际的问题似乎与setString
或我如何键入查询有关
但是,这会产生无效的列索引。您需要在
setString
语句中指定通配符