<分区>
public ResultSet getResourcesById(String id, String type)
{
try {
conn = connect();
selectStatement = "SELECT * FROM " + type + "WHERE ID LIKE ?";
preparedStatement = conn.prepareStatement(selectStatement);
preparedStatement.setString(1, "%ba%");
res = preparedStatement.executeQuery();
return res;
} catch (SQLException ex) {
Logger.getLogger(CatalogDB.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
大家好。我在我的系统中使用 java。我试图输入一个任意字符串,但它一直告诉我这个错误:
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 'LIKE '%ba%'' at line 1
有人可以向我解释为什么会出现此错误吗,我很确定我正确地遵循了语法。