8.5 Database Connection Management
The Oracle RDF Graph Adapter for Eclipse RDF4J provides support for Oracle Database Connection Pooling.
Instances of OracleSailStore
use a connection pool to manage connections to an Oracle database. Oracle Database Connection Pooling is provided through the OraclePool
class. Usually, OraclePool
is initialized with a DataSource
, using the OraclePool (DataSource ods)
constructor. In this case, OraclePool
acts as an extended wrapper for the DataSource
, while using the connection pooling capabilities of the data source. When you create an OracleSailStore
object, it is sufficient to specify the OraclePool
object in the store constructor, the database connections will then be managed automatically by the adapter for Eclipse RDF4J. Several other constructors are also provided for OraclePool
, which, for example, allow you to create an OraclePool
instance using a JDBC URL
and database username
and password
. See the Javadoc included in the Oracle RDF Graph Adapter for Eclipse RDF4J download for more details.
If you need to retrieve Oracle connection objects (which are essentially database connection wrappers) explicitly, you can invoke the OraclePool.getOracle
method. After finishing with the connection, you can invoke the OraclePool.returnOracleDBtoPool
method to return the object to the connection pool.
When you get an OracleSailConnection
from OracleSailStore
or an OracleSailRepositoryConnection
from an OracleRepository
, a new OracleDB
object is obtained from the OraclePool
and used to create the RDF4J connection object. READ_COMMITTED
transaction isolation is maintained between different RDF4J connection objects.
The one exception to this behavior occurs when you obtain an OracleSailRepositoryConnection
by calling the asRepositoryConnection
method on an existing instance of OracleSailConnection
. In this case, the original OracleSailConnection
and the newly obtained OracleSailRepositoryConnection
will use the same OracleDB object. When you finish using an OracleSailConnection
or OracleSailRepositoryConnection
object, you should call its close
method to return the OracleDB
object to the OraclePool
. Failing to do so will result in connection leaks in your application.
Parent topic: RDF Graph Support for Eclipse RDF4J