- CDI extension for Oracle UCP
This CDI portable extension provides support for injecting Oracle Universal Connection Pool data sources in your Helidon MicroProfile applications.
Prerequisites
Declare the following dependency in your project:
<dependency>
<groupId>io.helidon.integrations.cdi</groupId>
<artifactId>helidon-integrations-cdi-datasource-ucp</artifactId>
</dependency>content_copy
Injecting an Oracle Universal Connection Pool data source
The following examples show how to create a DataSource named orders in your application.
Field-injection example
@Inject
@Named("orders")
private DataSource ordersDataSource;content_copy
Constructor-injection example
private final DataSource ds;
@Inject
public YourConstructor(@Named("orders") DataSource ds) {
super();
this.ds = ds;
}content_copy
The extension implements this injection point by creating a PoolDataSource object in the application scope.
You can configure the object using MicroProfile config. For example, the data source created above can be configured as follows:
META-INF/microprofile-config.properties
javax.sql.DataSource.orders.connectionFactoryClassName = oracle.jdbc.pool.OracleDataSource
javax.sql.DataSource.orders.URL = jdbc:oracle:thin:@localhost:1521:ORCL
javax.sql.DataSource.orders.user = sys as sysoper
javax.sql.DataSource.orders.password = Oraclecontent_copy
Property names that start with javax.sql.DataSource.dataSourceName. are parsed, and the remaining portion of each name is treated as a Java Bean property of the oracle.ucp.jdbc.PoolDataSource class.