-2
我有一些jsp文件。它有一些變數。我想在mysql查詢中使用這些變量,如下所示。顯示類似使用Java和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''
您應該閱讀MySQL文檔 http://dev.mysql.com/doc/refman/5.0/en/show-tables.html –
您的錯誤消息最後有兩個單引號。你確定你沒有在你的SQL語句中傳遞這些信息嗎? –