On 21-11-2022 19:52, 'Hugo Larson' via firebird-java wrote:
> How "expensive" is it to open and close Jaybird connection every time a
> query is executed?
> Localhost and non localhost.
> Does the underlaying socket and network layer has any "keep-alive"
> Windows and Linux OS.
> What is your opinion?
When you create a new physical connection with Jaybird to Firebird 3.0
or higher, it requires at least three network roundtrips (not including
the TCP handshake) to establish a connection with wire encryption. More
if multiple authentication plugins need to be tried, or if database
encryption is used.
That is relatively expensive, so if you want to create and close a
connection for every database query your perform, I highly recommend you
use a connection pool like HikariCP, c3p0, or Apache DBCP.
A connection pool holds a collection of physical connections, and when
you ask for a connection, it returns you a logical connection (a wrapper
around a physical connection) from the pool. If you close that logical
connection, it will behave as a closed connection, but the physical
connection is returned to the pool for reuse.