I'm using MS Access and Spring Jbdc Template.
Where If I try to update the date in t开发者_如何学Cable using jdbctemplate it giving me error
"Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement."
This is the code:
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 });
Thanks in Advance, Santhosh
Date
is a keyword in Jet (the Access db engine) so it needs to be "escaped" with square brackets. Also, date literals are delimited by #
's. I'm not familiar enough with Java to know if your date is being formatted that way.
In any case, your sql string needs to be something like this:
"update timesheet set [date]=#4/5/2011# where task_id=20"
精彩评论