Menu

Connection Pooling Log in to Edit

marsupilami79

Connection Pooling in Zeos

Zeos provides a simple connection pooling driver. If you use it, connections don't get destroyed after using them but are returned to a pool of connections that are configured exactly the same.

Using connection pooling using TZConnection

If you want to use connection pooling using TZConnection, create a TZConnection object when needed. For the pool to work all TZConnection objects that should access the same pool need to be configured in the exactly same way. This should also include the order of parameters in TZConnection.Properties. To enable connection pooling on the connection object you need to prepend the protocol with pooled.. So the protocol firebird becomes pooled.firebird in that case.
Upon opening the connection, the pooling driver will look for a connection pool that matches your connection configuration. If no pool is found, a pool will be created. Then the driver will acquire a database connection from the pool for you to use. As long as you keep TZConnection open, the connection will be blocked for you to use. When you close your TZConnection object, the connection will be returned to the pool and wait there until it gets used again.

Using connection pooling on the DBC layer

If you want to use connection pooling on the dbc layer you go about creating your connection as usual. The only difference is that you prepend your protocol name with pooled.. So a connection url that started wit zdbc://firebird will start with zdbc://pooled.firebird. Connection pools are identified by their DBC layer URL. So you will need to use the same DBC layer URL on all connections that are to share the same pool. A connection acquired from the pool will be blocked as long as you keep the DBC layer connection open. It will be returned upon closing your connection.

Parameters accepted by the pooling driver

The pooling driver accepts the following parameters:

Parameter description
ConnectionTimeout How long a pooled connection will be kept in the pool. The time is specified in seconds. Zero = infinite.
MaxConnections The maximum numbers of connections this pool will hold. Zero = infinite
Wait A boolean paramater that specifies what happens if all connections in the pool are in use and a new connection is to be acquired from the pool. True: Wait until a connection is returned to the pool. False: Raise an exception.

All other parameters will be forwarded to the database driver.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.