1
我試圖從HSQLDB 2.2.8查詢數據與春天JDBC 3.1.2.RELEASE,這裏的語句:春天JDBC查詢之間date從HSQLDB
"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
爲什麼需要圍繞佔位符引用日期? – Vikdor
@Vikdor:如果沒有它們,我會得到另一個異常:「PreparedStatementCallback;錯誤的SQL語法[...];嵌套的異常是java.sql.SQLSyntaxErrorException:意外的令牌:?required:AND」 –