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 Deploy the Application and Configure the Load Balancer
Configuring an Oracle Data Source
To Integrate the JDBC Driver into GlassFish Server
Configuring Transport Layer Security (TLS)
To Configure GlassFish Server for TLS/SSL
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:
GlassFish Server has been installed and configured according to the example Deploying an Application to a Two-Instance Cluster.
The details about the database that the application uses are as follows:
The Oracle 11 database is running on empdb.example.com and listening for connections on the default port (1521).
The name of the database is EMP_PERKS.
The database user name is perk_app, and this user's password is perks4emps.
The perk-olator application looks up the JNDI name jdbc/emp_perks to access the data source.
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
Configuring the Oracle 11 database as a JDBC resource for the perk-olator application involves the following tasks:
Integrating the JDBC driver for Oracle 11 into GlassFish Server.
Creating a JDBC connection pool for the resource.
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, you copy its JAR file into the domain and then restart the domain and instances to make the driver available.
dashost$ cd /home/gfuser/glassfish3 dashost$ cp oracle-jdbc-drivers/ojdbc6.jar glassfish/domains/domain1/lib
dashost$ asadmin Use "exit" to exit and "help" for online help.
asadmin> restart-domain domain1 Command restart-domain executed successfully.
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.
asadmin> exit Command multimode executed successfully.
Use the create-jdbc-connection-pool(1) subcommand to create the JDBC connection pool, specifying the database connectivity values provided to you.
dashost$ asadmin Use "exit" to exit and "help" for online help.
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.
asadmin> ping-connection-pool Emp_Perks-Pool Command ping-connection-pool executed successfully.
asadmin> exit Command multimode executed successfully.
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.
dashost$ asadmin create-jdbc-resource --connectionpoolid Emp_Perks-Pool --target pmdcluster jdbc/emp_perks JDBC resource jdbc/emp_perks created successfully. pmd-i1: JDBC resource jdbc/emp_perks created successfully. pmd-i2: JDBC resource jdbc/emp_perks created successfully. Command create-jdbc-resource executed successfully.
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.