| Oracle® Containers for J2EE Enterprise JavaBeans Developer's Guide 10g (10.1.3.1.0) Part Number B28221-02 |
|
|
View PDF |
To create a data source for an Oracle database, you create a managed datasource. You can create a managed data source using the Application Server Control Console (see "Using Application Server Control Console") or deployment XML (see "Using Deployment XML").
For more information, see the following:
"Data Sources" in the Oracle Containers for J2EE Services Guide
You can use Application Server Control Console to create a managed data source dynamically without restarting OC4J.
For more information, see http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/index.html.
You can configure a managed data source for an Oracle database by configuring a connection-pool element and managed-data-source element in the data-sources.xml file, as Example 20-1 shows.
Example 20-1 data-sources.xml For an Oracle JDBC Data Source
<connection-pool name="ScottConnectionPool">
<connection-factory
factory-class="oracle.jdbc.pool.OracleDataSource"
user="scott"
password="tiger"
url="jdbc:oracle:thin:@//localhost:1521/ORCL" >
</connection-factory>
</connection-pool>
<managed-data-source
name="OracleManagedDS"
jndi-name="jdbc/OracleDS"
connection-pool-name="ScottConnectionPool"
tx-level="global"
/>
Be sure to specify a service-based connection URL in the connection-factory element (see "How do you Define a Connection URL in OC4J?").
By default, a managed data source supports global (two-phase commit) transactions. To configure a managed data source to support only local transactions, set the managed-data-source attribute tx-level to local. For more information, see "What Transaction Types do Data Sources Support?").
For more information, see the following:
http://www.oracle.com/technology/tech/java/oc4j/1013/how_to/index.html
http://www.oracle.com/technology/tech/java/newsletter/articles/oc4j_datasource_config.html
If you configure a managed data source using this method, you must restart OC4J to apply your changes. Alternatively, you can use Application Server Control Console to create a data source dynamically without restarting OC4J (see Using Application Server Control Console)