2

我正在尝试使用Spring JDBC 3.1.2.RELEASE从HSQLDB 2.2.8查询数据,这是语句:

"SELECT id, account_id, operator_id, amount, currency_type, date
    FROM account_entries WHERE account_id=? AND date BETWEEN DATE '?' AND DATE '?' + 1 DAY"

属性是:

1 (java.lang.Integer)
2012-09-06 (java.sql.Date)
2012-09-06 (java.sql.Date)

我收到的错误:

PreparedStatementCallback; SQL [SELECT id, account_id, operator_id, amount,
currency_type, date FROM account_entries WHERE account_id=?
AND date BETWEEN DATE '?' AND DATE '?' + 1 DAY]; data exception:
invalid datetime format; nested exception is java.sql.SQLDataException:
data exception: invalid datetime format
4

1 回答 1

2

您必须要么删除日期演员表:

... date BETWEEN ? AND ? + 1 DAY ...

或保留它们,但将参数作为格式正确的字符串 (YYYY-MM-DD) 而不是 java.sql.Date 对象传递。

于 2012-09-06T16:30:20.333 回答