Friday, April 24, 2009

JNDI Connection for OC4J

Today I’m going to go through on how to create the Database Connection Pool and JNDI on OC4J. If you’re not sure about the Database Connection Pool and JNDI please check the previous post.

I’ll use Oracle database as a data source and Oracle Enterprise Manager (EM) that comes with OC4J as a tool to create the Database Connection Pool and JNDI.

Access to Enterprise Manager (EM)

First you need to create a Connection Pool and then you can create a JNDI Data Source mapping to the Connection Pool. You can do such by using the EM so first let’s login to the EM. Here is the URL for the EM for the OC4J.

http://hostname:port/em

If you installed OC4J as part of your BI EE or BI Publisher installation then the port number is the same for your BI Publisher application, such as ‘9704’.

e.g. http://knishida-pc:9704/em

Once you have logged in to your EM you should see the window like the below.

Login to Oracle Enterprise Manager (OC4J Admin Console)
clip_image002[6]

Create Database Connection Pool

Now let’s create a Database Connection Pool. You need a JDBC connection information for your database for this task.

1. Click on the ‘Administration’ tab

clip_image004

2. Click ‘Go To Task’ link of ‘JDBC Resources’

clip_image006

3. Click ‘Create’ under Connection Pool

clip_image008

4. Click on the ‘Continue’ button (Leave all the fields as default)

clip_image010

5. Enter the following information

Name

Financial

Connection Factory Class

oracle.jdbc.pool.OracleDataSource

JDBC URL

jdbc:oracle:thin:@<hostname>:<port_number>:<sid>

Username

<database_schema_name>

Use Cleartext Password

Check

Password

<Password for the database_schema)

6. Click 'Test Connection' button, which is located under URL section

clip_image012

7. Click ‘Test’ button

clip_image014

If you get an error message make sure all the values entered at the above steps are correct.

8. Click on the ‘Finish’ button

Now you have created one Database Connection Pool at your OC4J server. Now you need to register it with JNDI.

Create Data Source (Register with JNDI)

Now you are going to create a ‘Data Source’, which is basically that you’re registering the previously created Database Connection Pool with JNDI so that you can access to the connection pool through the JNDI. This example will create a Financial JNDI data source.

1. Click on the ‘Create’ button under Data Sources

clip_image016

2. Click on the ‘Continue’ button (Leave all the fields as default)

clip_image018

3. Enter the following information

Name

Financial

Connection Factory Class

jdbc/FIN

Transaction Level

Leave as default

Connection Pool

Financial

clip_image020

You can enter any name for the JNDI location, but this will later be referenced as a JNDI data source so you want to a standard naming rule such as jdbc/<database_name> or something like that.

4. Click ‘Finish’ button

clip_image022

You can click the ‘Test Connection’ icon for the Data Source you have just created to make sure that it works. If it works fine that means now you have created one JNDI connection for your database!

I’ll talk about how to register the JNDI connection in BI Publisher tomorrow, so stay tuned!

1 comment:

  1. Hi Kan Nishida,

    Thanks for the wonderful posts.

    Is it possible for you to post on - Setting up connection pool in tomcat 5.5 and configuring it in BI Publisher 10g.

    Thanks.

    ReplyDelete