How to set transaction isolation level for the given transaction only.

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: pgsql-jdbc(at)lists(dot)postgresql(dot)org
Subject: How to set transaction isolation level for the given transaction only.
Date: 2020-08-13 12:52:48
Message-ID: CAKU4AWpH7K1Fu52e8SWiiFHUkB252_WiYecZGm7y6GWcTXytCg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

In database server, it has a default isolation level, and if we want to use
a different one, we can easily do:

begin;
set transaction isolation level xx;

commit;

We can see that the isolation level is set at the transaction level.
However when I
check the API, looks I can only set it at *connection* level via
Connection.setTransactionIsolation(x); If I want to rollback the original,
I have
to remember to reset it after this transaction which would be boring in
practice.
What would be the best practice for this?

--
Best Regards
Andy Fan

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Steven Schlansker 2020-08-13 15:16:32 Re: How to set transaction isolation level for the given transaction only.
Previous Message Sehrope Sarkuni 2020-08-13 11:50:13 [pgjdbc/pgjdbc] 0aa6d2: fix: Remove unused .ratignore (#1857)