JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server 3.1 Quick Start Guide
search filter icon
search icon

Document Information

1.  Quick Start for Basic Features

2.  Use Cases for Production Deployments

Deploying an Application to a Two-Instance Cluster

To Install and Configure the GlassFish Server Cluster

To Install and Configure iPlanet Web Server for Load Balancing

To Install the Load Balancer

To Deploy the Application and Configure the Load Balancer

Configuring an Oracle Data Source

To Integrate the JDBC Driver into GlassFish Server

To Create a JDBC Connection Pool

To Create a JDBC Resource

Next Steps

Configuring Transport Layer Security (TLS)

To Configure GlassFish Server for TLS/SSL

Shortcut for Configuring GlassFish Server for TLS/SSL

Shortcut: To Configure GlassFish Server for TLS/SSL

Configuring an Oracle Data Source

This example demonstrates how to configure an Oracle 11 database as a JDBC resource for an application. The information in this example is based on Chapter 12, Administering Database Connectivity, in Oracle GlassFish Server 3.1 Administration Guide, which explains how to configure any database that is supported by GlassFish Server as a JDBC resource.

The database in this example is used by the HR application perk-olator, which provides information to employees about special savings the company has arranged for its employees.

The assumptions for this example are as follows:

The configuration of the components in this example is shown in the following figure.

Figure 2-2 Sample Two-Instance Cluster Accessing an Oracle Database

image:Block diagram showing the configuration of the sample two-instance cluster with a separate database.

Configuring the Oracle 11 database as a JDBC resource for the perk-olator application involves the following tasks:

  1. Integrating the JDBC driver for Oracle 11 into GlassFish Server.

  2. Creating a JDBC connection pool for the resource.

  3. Creating the JDBC resource.


Note - In this example, line breaks are included for enhanced readability. These line breaks are not part of the syntax of the commands.


To Integrate the JDBC Driver into GlassFish Server

To integrate the JDBC driver, you copy its JAR file into the domain and then restart the domain and instances to make the driver available.

  1. On dashost.example.com, copy the JAR file for the JDBC driver into the domain's lib subdirectory.
    dashost$ cd /home/gfuser/glassfish3
    dashost$ cp oracle-jdbc-drivers/ojdbc6.jar glassfish/domains/domain1/lib
  2. Start the asadmin utility in multiple command mode (multimode).
    dashost$ asadmin
    Use "exit" to exit and "help" for online help.
  3. Restart the domain to make the JDBC driver available to the domain administration server (DAS).
    asadmin> restart-domain domain1
    Command restart-domain executed successfully.
  4. Restart instances in the domain to make the JDBC driver available to them.
    asadmin> list-instances
    pmd-i1   running
    pmd-i2   running
    Command list-instances executed successfully.
    asadmin> restart-instance pmd-i1
    Command restart-instance executed successfully.
    asadmin> restart-instance pmd-i1
    Command restart-instance executed successfully.
  5. Exit the multimode session for the asadmin utility.
    asadmin> exit
    Command multimode executed successfully.

To Create a JDBC Connection Pool

Use the create-jdbc-connection-pool(1) subcommand to create the JDBC connection pool, specifying the database connectivity values provided to you.

  1. On dashost.example.com, start the asadmin utility in multiple command mode (multimode).
    dashost$ asadmin
    Use "exit" to exit and "help" for online help.
  2. Create the JDBC connection pool.
    asadmin> create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname oracle.jdbc.pool.OracleDataSource --property "user=perk_app:password=perks4emps: url=jdbc\\:oracle\\:thin\\:@empdb.example.com\\:1521\\:EMP_PERKS" Emp_Perks-Pool
    JDBC connection pool Emp_Perks-Pool created successfully.
    pmd-i1:
    JDBC connection pool Emp_Perks-Pool created successfully.
    
    pmd-i2:
    JDBC connection pool Emp_Perks-Pool created successfully.
    
    Command create-jdbc-connection-pool executed successfully.

    In this command, note the use of two backslashes (\\) preceding the colons in the url property value. These backslashes cause the colons to be interpreted as part of the property value instead of as separators between property=value pairs.

  3. Verify connectivity to the database.
    asadmin> ping-connection-pool Emp_Perks-Pool
    Command ping-connection-pool executed successfully.
  4. Exit the multimode session for the asadmin utility.
    asadmin> exit
    Command multimode executed successfully.

To Create a JDBC Resource

Use the create-jdbc-resource(1) subcommand to create the JDBC resource, making sure to name it so that the perk-olator application can discover it using JNDI lookup.

Next Steps

After creating the Oracle data source for the perk-olator application, you need to deploy the application itself. Then, as the application is used over time, you can set a variety of JDBC connection pool features to optimize performance. For information about these features, see Configuring Specific JDBC Connection Pool Features in Oracle GlassFish Server 3.1 Administration Guide.