2012-09-14 36 views
1
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); 
String query = "select a.alert_id from alert a where (alert.last_execution is null or trunc(alert.last_execution) < to_date(?, 'dd/MM/yyyy')) and alert.frequency = ?"; 
jdbcTemplate.query(query, new Object[] {sdf.format(new Date()), "DAILY"}, new AlertRowMapper()) 

它retuns在查询线异常:弹簧JDBC模板查询与字符串/ VARCHAR参数

SQL状态[99999];错误代码[17004];无效的列类型;嵌套的异常是java.sql.SQLException中:无效的列式 在org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)

难道有人知道为什么它不工作?

感谢

回答

0

尝试直接发送Date对象为jdbcTemplate参数并从查询中删除to_date()部分。 Spring应该自动转换数据类型,而不是在应用程序中转换为字符串和从字符串转换。

+0

感谢您的答复,我试过和不工作,同样的错误:( – andre

+0

你能不能给我们的模式 – bazwilliams

+0

ALERT_ID \t数(19); 频率\t VARCHAR2(50); last_execution \t时间戳(0)与时区; – andre