Oracle
  Home arrow Oracle arrow Page 2 - Deploying J2EE Applications
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ORACLE

Deploying J2EE Applications
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2007-03-15


    Table of Contents:
  • Deploying J2EE Applications
  • Types of Data Sources
  • Creating Data Sources
  • Managing Data Sources
  • Deploying Web Application Modules

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Deploying J2EE Applications - Types of Data Sources
    ( Page 2 of 5 )

    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:

      <data-source 
          class=
    "com.evermind.sql.DriverManagerDataSource"
          name=ÓOracleDSÓ
          location="jdbc/OracleCoreDS"
          xa-location="OracleDS"
          ejb-location="jdbc/OracleDS"
          connection-driver="oracle.jdbc.driver.OracleDriver"
          username="scott"
         
    password="tiger"
          url="jdbc:oracle:thin:@// localhost:5521/oracle.regress.
      rdbms.dev.us.oracle.com"
         
    inactivity-timeout=Ó30Ó
      />

    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:

    <data-source  
      class= "com.evermind.sql.OrionCMTDataSource"
      location="jdbc/OracleDS"
      connection-driver="oracle.jdbc.driver.OracleDriver"
      username="scott"
      password="tiger" 
      url="jdbc:oracle:thin:@//localhost:5521/ oracle.regress.rdbms.dev.us.oracle.com"

    </data-source>

    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:

      <data-source 
          class= "com.my.DataSourceImplementationClass"
          name=ÓNativeDSÓ
          location="jdbc/NativeDS"
          username="user"
          password="pswd"
          url="jdbc:myDataSourceURL"
     
    </data-source>

    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
     

       

    ORACLE ARTICLES

    - Oracle's Turn to Play in the Sun
    - Implementing and Using Oracle`s Restore Poin...
    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek