Home arrow Oracle arrow Page 2 - Deploying J2EE Applications

Types of Data Sources - Oracle

In this week's part of a multi-part series covering OC4J and J2EE applications, you will learn how to deploy J2EE applications, create data sources, and more. This article is excerpted from chapter eight of the Oracle 10g Application Server Exam Guide, written by Sam Alapati (McGraw-Hill; ISBN: 0072262710).

  1. Deploying J2EE Applications
  2. Types of Data Sources
  3. Creating Data Sources
  4. Managing Data Sources
  5. Deploying Web Application Modules
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 5
March 15, 2007

print this article



There are three types of data sources you can use in OC4J:

  • Emulated data sources
  • Non-emulated data source
  • Native data sources

Emulated Data Sources   Emulated data sources emulate the XA (Transactional) protocol for JTA ( Java Transaction API) transactions and offer features such as OC4J caching and pooling and Oracle JDBC extensions (for Oracle databases). The need for emulated data sources arose because many JDBC drives didnít offer XA capabilities in earlier days.

An emulated data source doesnít provide full XA global transactional support, such as the two-phase commit, which is unsupported under emulated data sources. However, because they lack full transactional support, emulated data source connections tend to be quite fast in nature. If youíre using local transactions or global transactions that donít require the two-phase commit mechanism, emulated data sources are the recommended type of data source for you to use.

The following is a data-sources.xml configuration entry for an emulated data source:

      url="jdbc:oracle:thin:@// localhost:5521/oracle.regress.

Although you specify values for the location, ejb-location, and xa-location attributes when configuring an emulated data source in your data-source.xml file, you must only use the value specified by the ejb-location attribute when looking up that emulated data source. By now, youíre well aware that you use a JNDI tree to look up a data source. You must look up a data source in the following way (only the "jdbc/OracleDS" value is used in the JNDI lookup):


  Context ic = new InitialContext(); 
  DataSource ds = (DataSource) ic.lookup("jdbc/OracleDS");

Or this:

DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/OracleDS");
Connection con = ds.getConnection();

exam watch:  In the data-sources .xml file,
you must specify values for the location, xa-location, and ejb-location attributes. The first two attributes, however, are actually deprecated now, and only the value you specify for ejb-location is actually used as the location string. To be used in a JNDI lookup for retrieving the data source. Applications, EJBs, Servlets, and JSPs should use the ejb-location value to look up emulated data sources in the JNDI tree.

on the job:  If you want true two-phase commits in your transactions, you must use a non-emulated data source.

Non-Emulated Data Sources   A non-emulated data source provides full JTA services, meaning that the two-phase commit mechanism is provided as well. Oracle Corporation recommends you use non-emulated data sources. A non-emulated data source provides higher recovery and reliability as well as distributed database features, unlike the emulated data sources. Note that to run a non-emulated data source, you must use a Java-enabled database, such as the Oracle Database.

Hereís a typical data-sources.xml file for a non-emulated data source:

  class= "com.evermind.sql.OrionCMTDataSource"
  url="jdbc:oracle:thin:@//localhost:5521/ oracle.regress.rdbms.dev.us.oracle.com"


Note that JNDI lookups are performed using the value of the location attribute in the data-sources.xml file.

In the data-sources.xml file,

  • Location refers to the JNDI name bound to the data source in the JNDI name spaces.
  • The url, username, and password attributes refer to the database and default user name and password for retrieving connections to the database.
  • Class is the type of data source class to bind in the name space.

Native Data Sources   Native data sources are supplied by JDBC vendors, and are used to implement data sources. Vendors provide extensions to facilitate capabilities such as caching and pooling. OC4J supports native data sources, but because they donít provide JTA services such as commits and rollbacks, they canít be used in global transactions. Hereís how a data-sources.xml file looks for a native data source:

      class= "com.my.DataSourceImplementationClass"

Exam watch:  Native data sources donít support JTA transactions. Both emulated as well as non-emulated data sources support JTA transactions, but only the non-emulated data sources support true two-phase commit (an emulated data source can only emulate a two-phase commit).

You can manage data sources through the Application Server Controlís Application Data Sources page. You can reach this page by clicking the Administration tab on the OC4J home page, and then clicking on Data Sources under the Application Defaults section. From the Application Data Sources page, you can perform the following functions:

  • View data source information for all applications, including the data source name, the JNDI location, and class and JDBC Driver information.
  • Create, delete, and modify data sources.
  • View performance statistics for data sources (only for non-emulated data sources).

The Data Sources page can be used to connect top Oracle as well as non-Oracle databases. For Oracle database connections, you must either configure a non-emulated Data Source that is purely Oracle based or use an emulated Data Source, which involves a wrapper around an Oracle Data Source.

on the job:  Use the com.evermind.sql.DriverManagerDataSource with the Merant JDBC drivers to connect to Oracle databases.

>>> More Oracle Articles          >>> More By McGraw-Hill/Osborne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Oracle Java Security Woes Continue
- Oracle's New IaaS Cloud Option: There's a Ca...
- Oracle Acquires Eloqua to Boost Cloud Presen...
- Choosing Innovation: Oracle Survey Insights
- Oracle Fixes Privilege Escalation Bug
- Oracle`s Communications Service Availability...
- Oracle Releases Exalytics, Taleo Plans
- Oracle Releases Communications Network Integ...
- Oracle Releases Communications Data Model 11...
- Oracle Releases PeopleSoft PeopleTools 8.52
- Oracle Integrates Cloudera Apache Distro, My...
- Oracle Releases MySQL 5.5.18
- Oracle Announces NoSQL Database Availability
- Sorting Database Columns With the SELECT Sta...
- Retrieving Table Data with the LIKE Operator

Developer Shed Affiliates


Dev Shed Tutorial Topics: