A. How to Create a Connection Pool in BEA WebLogic Server

1. Open the admin console of the BEA WebLogic Server

admin console of the BEA WebLogic Server

2. Click on the link "Connection Pools"

Configure a new JDBC Connection Pool

3. Click on Configure a new JDBC Connection Pool . Select the database type and database driver . This will be decided by the database you use.

In this example, we are going to connect to MS SQL server . Hence we are selecting “Database Type” as “MS SQL Server” and a suitable driver for MS SQL Server

Configure a new JDBC Connection Pool

4. Click on Continue. Provide required details like connection pool name, database name, database username , database password, database port number, database host name etc.

Configure a new JDBC Connection Pool

Configure a new JDBC Connection Pool

5. Click on "Test Driver Configuration" to see if we are able to establish a connection to the given database. If everything is fine, you will get a screen as given below.

Configure a new JDBC Connection Pool

6. Click on "Create and Deploy". The connection pool will be created as given below

Configure a new JDBC Connection Pool

B. How to Create a Data Source in BEA WebLogic Server

A JDBC data source is an object which points to a JDBC connection pool or multi pool. Applications use JDBC data source to get a database connection from the connection pool or multi pool to which the data source points.

So now we need to configure a JDBC data source. Please follow the below steps for that.

1. Open the admin console of the BEA WebLogic Server

admin console of the BEA WebLogic Server

2. Click on data sources.

admin console of the BEA WebLogic Server

3. Give a name for your data source . Also give a JNDI name for your data source. Click on "Continue"

admin console of the BEA WebLogic Server

4. Select the connection pool name to which this data source should be associated to. Click on "Continue"

admin console of the BEA WebLogic Server

5. Click on "Create"

admin console of the BEA WebLogic Server

C. How to get a connection from the connection pool we created

We can get a connection from the connection pool using the data source. Use the below code for this

Context context = new InitialContext();
DataSource dataSource = (DataSource)context.lookup("Give the JNDI Name of the Data Source");
Connection connection = dataSource.getConnection();
 
 
 
 
Comments(0) Sign in (optional)
 
Add a new comment...  (Use Discussion Board for posting new aptitude questions.)

Name:
Email: (optional)
6 + 10 = (please answer the simple math question)

Post Your Comment
X  
View & Edit Profile Sign out
X
Sign in
Google
Facebook
Twitter
Yahoo
LinkedIn
X