我試圖做一個從表中選擇,這在我的數據庫與其他所有表工作正常,但是當我嘗試以下方法我收到一個錯誤:SELECT * FROM表拋出錯誤的JDBC
db.makeQuery("SELECT * FROM References");
的呼叫:
public ResultSet makeQuery(String query) throws Exception
{
preparedStatement = connect.prepareStatement(query);
resultSet = preparedStatement.executeQuery(query);
return resultSet;
}
然後引發以下錯誤:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
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 'References' at line 1
我看起來很奇怪對我來說,因爲這個語句的工作:
db.makeQuery("select * from Products");
是的,改變表的名字做到了。謝謝! – Medo 2012-07-05 12:18:10