运行此代码时出现此未知错误:
String SELECT_getWhenValueChanged = "SELECT a.* FROM status AS a WHERE a.value <> (SELECT b.value FROM status AS b WHERE a.idCategory = ? AND b.idCategory = a.idCategory and a.timeStamp > b.timeStamp ORDER BY b.timeStamp DESC LIMIT 1) ORDER BY timeStamp DESC";
try {
Survey surveyTemp = new Survey();
surveyTemp = (Survey) getJdbcTemplate()
.queryForObject(SELECT_getWhenValueChanged,
new Object[] { categoryId, categoryId },
new SurveyMapper());
/*
* SQL Question ask when the value has changed and get the value
* that changed from and changed to, the first one is the current
* value and the second is the value before it changed
*/
if (!surveyTemp.getTimestamp().isEmpty()
&& !presentSurvey.getTimestamp().isEmpty()) {
presentSurvey.setTimestamp(surveyTemp.getTimestamp());
}
} catch (BadSqlGrammarException e) {
e.printStackTrace();
} catch (EmptyResultDataAccessException e) {
} catch (Exception e) {
e.printStackTrace();
}
return presentSurvey;
有人知道这是什么意思吗?
org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT a.* FROM status AS a WHERE a.value <> (SELECT b.value FROM status AS b WHERE a.idCategory = ? AND b.idCategory = a.idCategory and a.timeStamp > b.timeStamp ORDER BY b.timeStamp DESC LIMIT 1) ORDER BY timeStamp DESC]; Parameter index out of range (2 > number of parameters, which is 1).; nested exception is java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
我不擅长SQL,所以不知道如何解决这个问题......