Connection Pool Create Data Source in Weblogic 8.1

Connection Pool Create Data Source in Weblogic 8.1


What is connection pool?

Generally, whenever a connection is sought with the database, dynamically a connection (in JDBC terms, a java.sql.Connection object) is created. Creating a connection is very costly (takes more time) in terms of performance. To overcome this bottleneck in large databases, the application servers like Weblogic, WebSphere or JBoss etc. comes with a reserve of Connection objects, known as connection pool, created at the time of server start up. This pool of connections is stored in the server cache. Whenever, the client requires a connection object, a connection object from the pool is given to the client to use. This increases the performance as the connection object is not created on the fly dynamically. When the job of the client is over, the connection object is returned back to the pool, ready to serve another request. These Connection objects in the pool or reusable. The application servers give the facility to configure the pool with the parameters of number of connection objects created (pool size) by default when the server starts, how many connection objects to be created when the pool exhausts (the increment) etc.

What is data source?

As the name implies, a data source represents a source of data. In Java programming language, a data source represents a source of connection pools. javax.sql.DataSource object is the preferred alternative way of using DriverManager for connecting to a database. The DataSource interface comes with two overloaded methods of getConnection() that return an object of Connection interface. The advantage of Datasource is that it can be connected to a connection pool and also can be given a logical JNDI name which can be used in all the programs wherever to connect to the database.

The aim of this notes is creating a connection pool and associating the pool with a JNDI name.

Two steps are involved here. First step is creating a connection pool and the second step is attaching it to a data source. Give a JNDI name to the data source (here, I gave as "SNRaoDataSource"). This name we use in all our future programs to connect to Oracle database (with implicit connection pool usage). Following notes gives step-by-step screens.

1. Creating Connection Pool

Open weblogic server home page as follows.

Programs –> BEA Weblogic Platform 8.1 –> Examples –> Weblogic Server Examples –> Launch Weblogic Server Examples

When you click over Launch Weblogic Server Examples, home page of Weblogic application server opens. Following is the home page.

a)
Connection Pool

b) Click over Administrative Console.

It opens a Login screen as follows.

Connection Pool

Username: weblogic (gets by default filled)
Password: weblogic

Click Sign In button. It opens following screen.

c)

Connection Pool

Click over Connection Pools under category Service Configuration/JDBC.

d)

Connection Pool

Click over Configure a new JDBC Connection Pool……. It opens the following screen.

e)

Connection Pool

The above screen is the default that appears. Do the following.

Database Type: Dropdown PointBase and select Oracle.
Database Driver: Select *PointBase’s Driver (Type 4 XA) Versions 4.X

Click Continue.

f) Following screen appears.

Connection Pool

Fill up as follows:

Name: SNRaoPool (Give some name you like, remember it is not the JNDI name). On this name connection pool is created in the weblogic application server.
Database Name: orcl1 (it is SID)
Host Name: localhost
Port: 1521 (the default filled)
Database User Name: scott
Password: tiger
Confirm Password: tiger

After filling up all the text boxes, click Continue button. You get the next screen.

Note: You can check your database name (SID) by going to the windows explorer Oracle installation directories as in the following screen. E is the drive where Oracle is installed on my system.

image

g)

Connection Pool

You can check the data you furnished correct or not by clicking over the button Test Driver Configuration.

h) When the database data is correct, you get the following successful screen.

Connection Pool

Click over the button Create and deploy.

i) You get the following screen.

Connection Pool

You can observe SNRaoPool in the list of already existing pools (with true deployed).

Now you are ready with connection pool. This connection pool is to be attached to a data source. Following are the steps. Go to Weblogic Server Home page (not actual home page, you have started with) by clicking over home icon on the right top corner. You get the next screen.

2. Creating DataSource and giving a JNDI name

a)

image

Now click over the hyperlink Data Sources under Services Configuration/JDBC category. You get the following screen.

b)

Connection Pool

Click over Configure a new JDBC Data Source.

c)

Connection Pool

Name: SNRSource (give some name you like and on this name data source is created in WLAS (Weblogic Application Server). It is not JNDI name).

JNDI Name: SNRaoDataSource (this is the JNDI name which you are waiting for a long time. It is the JNDI name you should use in later programs).

Click Continue button. You get next screen.

d)

image

Pool Name: Click over the dropdown list and select SNRaoPool.
(remember, SNRaoPool is the name you have given while creating the connection pool in the 1st step. Page No. 5 and 7).

Click Continue button.

e)

image

By default exampleServer checkbox is selected and keep it like that. Click over Create button. Weblogic comes with many servers inside working. examplesServer is one among them. That is, the data source is configured on examplesServer.

f)
image

You can observe the JNDI name SNRaoDataSource. You can use SNRaoDataSource in future in all Spring applications to connect to the database Oracle (with SID name orcl1). The advantage of using connection pool is it increases the performance of database access.

Leave a Reply

Your email address will not be published. Required fields are marked *