Cannot use a LIKE query in a JDBC PreparedStatement?

前端 未结 7 1792
生来不讨喜
生来不讨喜 2020-12-01 06:11

The query code and query:

ps = conn.prepareStatement(\"select instance_id, ? from eam_measurement where resource_id in (select RESOURCE_ID from eam_res_grp_r         


        
相关标签:
7条回答
  • 2020-12-01 07:04

    Omit the ' around the ?. Without the ', ? is a placeholder for a parameter. With it, it's an SQL string (i.e. the same as "?" in Java).

    Then you must concatenate the string on the Java side; you can't pass SQL functions as parameters to queries; only basic values (like string, integer, etc) because the JDBC driver will convert the parameter to the SQL type the database expects and it cannot execute SQL functions in this step.

    0 讨论(0)
提交回复
热议问题