let me put this way
table employee ( id PrimaryKey, name )
In Java ( just little pseudo-code way )
try {
conn.setAutoCommit(false);
try { executeUpdate("insert into employee(id,name) values(1, 'K1')"); } catch ...
try { executeUpdate("insert into employee(id,name) values(1, 'K1')"); } catch ...
try { executeUpdate("insert into employee(id,name) values(1, 'K2')"); } catch ...
conn.commit();
} catch ...
throws error
1. duplicate key value violates unique constraint "employee_pkey"
2. current transaction is aborted, commands ignored until end of transaction block
In PL/SQL ( similar error thrown when used BEGIN-END )
postgres=# begin;
BEGIN
postgres=# insert into employee values (1,'aa');
INSERT 0 1
postgres=# insert into employee values (2,'bb');
INSERT 0 1
postgres=# insert into employee values (3,'cc');
INSERT 0 1
postgres=# insert into employee values (1,'aa');
ERROR: duplicate key value violates unique constraint "employee_pkey"
DETAIL: Key (eid)=(1) already exists.
postgres=# insert into employee values (4,'dd');
ERROR: current transaction is aborted, commands ignored until end of transaction block
my question Java setAutoCommit (false) is behaving like PL/SQL BEGIN-END