0
子查詢我有以下查詢,其中第一個參數本身就是一個子查詢設定參數,使用JDBC的PreparedStatement
的Java代碼:
String query = select * from (?) where ROWNUM < ?
PreparedStatement statement = conn.preparedStatement(query)
statement.setString(1, "select * from foo_table")
statement.setInt(2, 3)
當我運行Java代碼,我得到一個異常。什麼選擇我必須作出的第一個子查詢statement.setString(1, "select * from foo_table")
參數?
你不能傳遞一個子查詢作爲一個'PreparedStatement'的參數。您需要連接的SQL成一個字符串 –
_Why_你想在子查詢作爲參數傳遞? –
爲了避免SQL注入 – tintin