Re: JDBC behaviour
От | Thomas Kellerer |
---|---|
Тема | Re: JDBC behaviour |
Дата | |
Msg-id | nabpk4$4sc$1@ger.gmane.org обсуждение исходный текст |
Ответ на | Re: JDBC behaviour (Sridhar N Bamandlapally <sridhar.bn1@gmail.com>) |
Список | pgsql-jdbc |
Sridhar N Bamandlapally schrieb am 21.02.2016 um 03:20: > Hi > > My expectation is simple, please refer below > > create table employee(empid numeric(4) primary key, ename varchar(20)); > > from Java/jdbc code, conn.setAutoCommit(false) > > insert into employee values(1, 'K1'); > insert into employee values(1, 'K1'); > insert into employee values(2, 'K2'); > > by looking at exceptions i may rollback or commit, i.e. conn.rollback() or conn.commit() > if I rollback table should be empty, > if I commit table should have 2 rows > > is there any way is possible ? Use on conflict do nothing: insert into employee values(1, 'K1') on conflict (empid) do nothing; insert into employee values(1, 'K1') on conflict (empid) do nothing; insert into employee values(2, 'K2') on conflict (empid) do nothing; This can be combined with a PreparedStatement and batching if needed.
В списке pgsql-jdbc по дате отправления: