Re: JDBC behaviour - Mailing list pgsql-jdbc

From Sridhar N Bamandlapally
Subject Re: JDBC behaviour
Date
Msg-id CAGuFTBWODgA_-JLGWBHqg_2NUZWDiKZSUkNgFJj_CZ4gZcqjVQ@mail.gmail.com
Whole thread Raw
In response to Re: JDBC behaviour  (John R Pierce <pierce@hogranch.com>)
Responses Re: JDBC behaviour
Re: JDBC behaviour
List pgsql-jdbc
The code/framework is written to handle batch inserts, which is common for all databases

I feel, PostgreSQL JDBC may need to modify setAutoCommit(false) code to "implicit savepoint - on error - rollback to savepoint"



On Thu, Feb 18, 2016 at 3:59 PM, John R Pierce <pierce@hogranch.com> wrote:


if you want each insert to work indepedently yet stay with the transaction model, then each insert should be its own transaction...


    conn.setAutoCommit(false);
    executeUpdate("insert into employee(id,name) values(1, 'K1')"); conn.commit();
    executeUpdate("insert into employee(id,name) values(1, 'K1')"); conn.commit();
    executeUpdate("insert into employee(id,name) values(1, 'K2')"); conn.commit();

otherwise the way you wrote it, its a single transaction.   all three inserts have to succeed, otherwise, all three are rolledback.    why is that so hard to understand?


--
john r pierce, recycling bits in santa cruz



--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

pgsql-jdbc by date:

Previous
From: John R Pierce
Date:
Subject: Re: JDBC behaviour
Next
From: Dave Cramer
Date:
Subject: Re: JDBC behaviour