但是在使用batchUpdate()函数时遇到了执行结果为-2的问题,先查查API:
batchUpdate public int[] batchUpdate(String[] sql) throws DataAccessException Description copied from interface: JdbcOperations Issue multiple SQL updates on a single JDBC Statement using batching. Will fall back to separate updates on a single Statement if the JDBC driver does not support batch updates. Specified by: batchUpdate in interface JdbcOperations Parameters: sql - defining an array of SQL statements that will be executed. Returns: [b]an array of the number of rows affected by each statement[/b] Throws: DataAccessException - if there is any problem executing the batch
返回值为一个整型的数组,数组的每个元素值对应每条SQL影响的数据库的记录数。
这样无论如何负值也无法理解的。网上查询有地方说是驱动的问题,然后动手用JDBC的PreparedStatement测试了一把,同样的结果。那么说,出现这种结果的根本原因是JDBC驱动。
从Oracle的官网下载了Oracle11gR2的最新驱动ojdbc6.jar,目前问题仍然存在。。。