我收到以下错误,但我不明白为什么:
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; 错误的 SQL 语法 [UPDATE da_tracking SET ins_name= xyz, ins_dev_scripted = False WHERE ins_ID = 12]; 嵌套异常是 java.sql.SQLException: Invalid parameter index 1。
------------------------ dao class-----
public int save(DboBean record) {
// TODO Auto-generated method stub
String sql = "UPDATE da_tracking"
+ " SET ins_name= " + record.getDboDevName()+ ","
+ " ins_dev_scripted = " + record.getDevScripted()
+ " WHERE ins_ID = " + record.getDboId();
Object[] params = new Object[] {record.getDboDevName(), record.getDevScripted()};
int[] types = new int[]{Types.VARCHAR, Types.BIT};
return jdbcTemplate.update(sql, params, types);
}
----------------------------Junit-----
bean.setDboDevName("xyz");
bean.setDboId(12);
int rowsAffected = objDao.save(bean);
System.out.println("Object is updated [" + bean.getDboId() + ", " + bean.getDboDevName() +
", " + bean.getDevScripted() + "]");
你知道为什么吗??我的删除和读取方法有效。