Re: Return Codes of BatchUpdateException in PostgreSql 9.6

From: Tillmann Schulz <tillmann73(at)yahoo(dot)de>
To: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Return Codes of BatchUpdateException in PostgreSql 9.6
Date: 2016-10-12 11:42:53
Message-ID: 1551770832.7977601.1476272573709@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello again,

>>since htere's no SQL in your report, I'd suggest its probably a JDBC
>>issue.

Yes, I am talking about JDBC-Batch-Update funcionallity in Java. So it could be a jdbc driver issue.
Is there a special mailing list for the driver?

>>no idea what you mean when you say batch updates... SQL

I try to give an example.

Preparation, with SQL
-----------------------------

CREATE TABLE TESTTABLE (id INTEGER);

INSERT INTO TESTTABLE VALUES (5);

Java Code with Java JDBC Update
-----------------------------

for( int i = 0; i < 10;i++ )
{
stmt.addBatch("INSERT INTO TESTTABLE VALUES('"+i+"')" );
stmt.executeBatch();
con.commit();
}
catch( java.sql.BatchUpdateException x )
{
final int[] updateCounts = x.getUpdateCounts();
}

In the sample, the 6th statement has an error, because the value 5 already exists in the database.

In this case in postgres 9.6 all fields updateCounts[0..9] are -3 (Statement.EXECUTE_FAILED)
The behavior prior 9.6 was, that only the specific entry in updateCounts[5] has the error code -3

I hope this helps,

Tillmann Schulz

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message alena.zubets 2016-10-12 15:15:01 BUG #14368: Strange behaviour of set_config() in case of transaction failure
Previous Message jan.kort 2016-10-12 10:45:37 BUG #14367: Pressing execute 20-30 times really fast causes loop of error messages