cmaster
unread,Aug 25, 2008, 3:17:07 AM8/25/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to DBExplorer
在项目中date类型的字段修改是用spring的NamedParameterJdbcTemplate,如int updateRows =
service.namedJdbcTemplate.update(sql, params);传入的参数是String例
如'2008-08-27',这在项目中是没有问题的,我写了个测试测这个功能确报错:
public void testNameJdbc()
{
String sql ="update BOOK_INFO SET PRESSDATE=:PRESSDATE where
AUTO_ID=:AUTO_ID";
Map<String, Object> params = new HashMap<String, Object>();
params.put("PRESSDATE", "2008-08-27");
// System.out.println("field value is :"+value.getValue());
params.put("AUTO_ID", "4");
System.out.println("test this service:"+this.service);
HelperDBInfoServiceTable helpservice = new
HelperDBInfoServiceTable (this.service,log);
System.out.println("test helpservcie :"+helpservice);
helpservice.executeUpdate(sql, params);
}
报错如下: 执行SQL[update BOOK_INFO SET PRESSDATE=:PRESSDATE where
AUTO_ID=:AUTO_ID]出错:PreparedStatementCallback; SQL [update BOOK_INFO
SET PRESSDATE=? where AUTO_ID=?]; ORA-01861: 文字与格式字符串不匹配
; nested exception is java.sql.SQLException: ORA-01861: 文字与格式字符串不匹配
同样参数为啥我的测试用例通不过那?