FirebirdConnection.setTransactionParameters(TransactionParameterBuffer tpb) and ConnectionPool Behavior

5 views
Skip to first unread message

Erwan Tanajaya

unread,
May 8, 2024, 6:14:55 AMMay 8
to firebird-java

Hi !
I set TransactionParameterBuffer to setTransactionParameter, it's just run for one next transaction or all next transaction ?

If it run for all next transaction what i can do to reset the TransactionParameter before returning it to connection pool ?

Best Regards,
Erwan T

Mark Rotteveel

unread,
May 8, 2024, 6:20:01 AMMay 8
to firebird-java
As I also posted on GitHub (I'm very bad at following my own rules ;):
your question is answered by the Javadoc of the method:
|setTransactionParameters​([TransactionParameterBuffer tpb)|
<https://www.firebirdsql.org/file/documentation/drivers_documentation/java/5.0.x/docs/org/firebirdsql/jdbc/FirebirdConnection.html#setTransactionParameters(org.firebirdsql.gds.TransactionParameterBuffer)>:


/This method does not change the TPB mapping, but replaces the
mapping for the current transaction isolation until
|Connection.setTransactionIsolation(int)| is called./

In other words, it will keep using the specified TPB until
|setTransactionIsolation(int)| is called, which hopefully your
connection pool does to reset it back.

Mark

--
Mark Rotteveel

Erwan Tanajaya

unread,
May 10, 2024, 5:56:18 AMMay 10
to firebi...@googlegroups.com
Hi Mark,

Thank you for your very spiritful answer :D
I already read the javadoc, just want to make sure what happens and hoping no extra effort should be taken

if i default transaction isolation is 2 then i set TPB mapping and call setTransactionIsolation(2) will it reset or i should setTransactionIsolation to value other than 2 before closing the connection ?

just for info i am using Tomcat Connection Pool.

Best Regards

Mark Rotteveel

unread,
May 10, 2024, 6:31:12 AMMay 10
to firebi...@googlegroups.com
On 10/05/2024 05:12, Erwan Tanajaya wrote:
> Thank you for your very spiritful answer :D
> I already read the javadoc, just want to make sure what happens and
> hoping no extra effort should be taken
>
> if i default transaction isolation is 2 then i set TPB mapping and call
> setTransactionIsolation(2) will it reset or i should
> setTransactionIsolation to value other than 2 before closing the
> connection ?

Any call to setTransactionIsolation(int) with a valid isolation level
value (I highly recommend to use the constants defined in
java.sql.Connection instead of literal) will reset the value to the
value defined in the transaction mapping of the connection, removing the
overridden value.

> just for info i am using Tomcat Connection Pool.

If you explicitly configure the defaultTransactionIsolation property on
your Tomcat connection pool, Tomcat will reset it for you automatically.
Otherwise it will not touch it and you'd need to manually reset it.
Setting defaultTransactionIsolation to
Connection.TRANSACTION_READ_COMMITTED (or 2) will use the same isolation
level as Jaybird's default.

Mark
--
Mark Rotteveel

Erwan Tanajaya

unread,
May 11, 2024, 4:35:41 AMMay 11
to firebi...@googlegroups.com
Great, i will using defaultTransactionIsolation property then

Thank you Mark

Best Regards,
Reply all
Reply to author
Forward
0 new messages