我有一些jsp文件。它有一些变量。我想在 mysql 查询中使用这些变量,如下所示。
String given_session="monsoon";
String given_year="2012";
// note above two will be dynamically added.
ResultSet rs11 = (ResultSet) st11.executeQuery("show tables like '%_Assessment_" + given_session + "_" + given_year+"'");
我得到以下异常:
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%_Assessment_Monsoon_2013''