Using a shared connection

Every JDBC service instance keeps its own database connection and uses it to access the database. It can be useful in some cases to be able to share a connection between different JDBC service instances in order to let the statements executed from different services be done within a single transaction.

If a service invoker can share a connection between different JDBC service instances, the JDBC services in the external definition files should uses a connection alias (a tag in the services definition file). The JDBCServicesConnectionManager must then manage the establishment and release of the connection. When the service invoker requests a connection to the JDBC service instance, the request is passed to the JDBCServicesConnectionManager as follows:

Whenever an service invoker closes the connection being used by a JDBC service instance, the JDBCServicesConnectionManager checks whether this connection is being used by other instances, and it will only close the connection or release it to the connection pool if no instance is still using it.