使用Spring jdbcTemplate更新MS Access中的日期

我正在使用MS Access和Spring Jbdc模板。 如果我尝试使用jdbctemplate更新表中的日期,它会给我错误
"Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement."
这是代码:
Calendar cal = Calendar.getInstance();
java.sql.Date sqlDate = new java.sql.Date(cal.getTime().getTime());

JdbcTemplate jdbcTemplate = new JdbcTemplate(ds);
int id = jdbcTemplate
   .queryForInt("select TASK_ID from timesheet where task_id=1");
jdbcTemplate.update("update timesheet set date=? where task_id=20",
                     new Object[] { sqlDate });
提前致谢, Santhosh     
已邀请:
Date
是Jet(Access数据库引擎)中的关键字,因此需要使用方括号“转义”。此外,日期文字由
#
分隔。我对Java不熟悉,知道你的日期是否正在以这种方式格式化。 无论如何,你的sql字符串必须是这样的:
"update timesheet set [date]=#4/5/2011# where task_id=20"
    

要回复问题请先登录注册