1. 程式人生 > >java.sql.BatchUpdateException: No value specified for parameter 9

java.sql.BatchUpdateException: No value specified for parameter 9

專案中資料庫操作遇到的小bug,意思就是說,沒有值再去給第九個引數賦值了,就是說新增的value的個數與sql語句中的佔位欄位個數不相同。
我的程式碼中只添加了八個引數:
pstmt.setInt(++i, statsCommon.getPlatform().getId());
pstmt.setInt(++i, statsCommon.getDate().getId());
pstmt.setInt(++i, inboundDimension.getInbound().getId());
pstmt.setInt(++i, inboundValue.getUvs());
pstmt.setInt(++i, inboundValue.getVisit());
pstmt.setString(++i, conf.get(GlobalConstants.RUNNING_DATE_PARAMES));
pstmt.setInt(++i, inboundValue.getUvs());
pstmt.setInt(++i, inboundValue.getVisit());
這是我的sql語句,其中有九個佔位?:
insert into stats_inbound

(
platform_dimension_id,
date_dimension_id,
inbound_dimension_id,
active_users,
sessions,
created
)values(?,?,?,?,?,?,?) on duplicate key update active_users=?,sessions=?
括號裡明顯多了一個問號,去掉即可。