Reputation: 1036
I am trying to use the executeBatch feature of prepared statement. In the array that returns, all the values in -2. Can anybody tell me what is the meaning of that value ?
Value at index 0 is = -2
Value at index 1 is = -2
Value at index 2 is = -2
Value at index 3 is = -2
Value at index 4 is = -2
Value at index 5 is = -2
In the DB, all rows are inserted correctly.
Thanks, SD
Upvotes: 0
Views: 764
Reputation: 344
It also depends upon which version of database you are using. If you are getting -2 which means SUCCESS_NO_INFO, you must be using Oracle 11g. One problem with Oracle 11g was, that even if there was no row updated, it will still return -2. Or if no row deleted, it will still return -2.
In Oracle 12c, the response of executeBatch is enhanced. It used to be like you observed an array of constants of -2 or -3. The -2 is for successful executions and -3 for failures. Now with 12c, it is an array of integers with actual row affected by the sql statements. e.g. [2, 3, 0, 1, 10...]. First index telling the two rows are impacted by executing the first sql, second sql impacted 3 rows and so on...
Upvotes: 0
Reputation: 431
It means SUCCESS_NO_INFO
From java.sql.Statement:
/**
* The constant indicating that a batch statement executed successfully
* but that no count of the number of rows it affected is available.
*
* @since 1.4
*/
int SUCCESS_NO_INFO = -2;
You can use those constants to check whenever the response you get is the desired one. In your case it looks like all the calls were successful. But, there is no more additional info to return (e.g.: rows affected)
Upvotes: 1