0% found this document useful (0 votes)
2 views

Configure a JDBC Data Source in Oracle WebLogic Server 1700453941

This document provides a step-by-step tutorial for configuring an Oracle WebLogic Server with a JDBC data source using Oracle Database. It outlines the necessary prerequisites, including software installations and environment variable configurations, and details the process for setting up the database, starting the WebLogic Server, and deploying a sample web application. Additionally, it explains how to test the JDBC data source through the deployed application interface.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Configure a JDBC Data Source in Oracle WebLogic Server 1700453941

This document provides a step-by-step tutorial for configuring an Oracle WebLogic Server with a JDBC data source using Oracle Database. It outlines the necessary prerequisites, including software installations and environment variable configurations, and details the process for setting up the database, starting the WebLogic Server, and deploying a sample web application. Additionally, it explains how to test the JDBC data source through the deployed application interface.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Name: Prathamesh Sawant

LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

What Do You Need?


 An installation of Oracle WebLogic Server 12c.
See http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html.
 A running instance of the Oracle Database 11g or later. In this tutorial, Oracle Database
Express Edition 11.2 is used. Also, ensure that you have the required credentials to start
the database.
 A properly configured WebLogic Server domain containing an Administration Server with
following settings:
o Domain Directory: /u01/domains/ExampleDomain
o Administration Server listen address and port
number: localhost:7001
o Domain administrator credentials: The user name and password you
specified when you created the domain.
 An example application, which is available for downloaded here. This application archive
contains three files:
o testds_oracle.sql, a SQL script to configure the required schema
in the Oracle Database.
o testds.war, a simple web application used to test the configured data
source.
o deploy.sh, a WebLogic Scripting Tool (WLST) script used to deploy the
web application.

Conventions
This tutorial uses the following conventions:

Entity Value

JAVA_HOME Environment
/u01/app/jdk
Variable

ORACLE_HOME Environment
/u01/app/oracle/product/11.2.0/xe
Variable

ORACLE_SID Environment
XE
Variable

PATH Environment Variable $ORACLE_HOME/bin:$PATH

WL_HOME Environment Variable /u01/app/fmw/wlserver/server


APP_HOME Environment
/tmp/downloads/JDBC
Variable
Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

Configure the Oracle Database


To configure the database required by the JDBC client application:

1. Open a terminal window and navigate to the APP_HOME directory.

$ cd ${APP_HOME}
2. Ensure that the database environment variables such
as ORACLE_HOME, ORACLE_SID, and PATH are set by printing them out using
the echo command:

3. $ echo ${ORACLE_HOME}
4. /u01/app/oracle/product/11.2.0/xe
5. $ echo ${ORACLE_SID}
6. XE
7. $ echo ${PATH}

${ORACLE_HOME}/bin:$PATH
Note: The values of your environment variables may be different. If there are no values
printed, then set the variables to the proper values:

$ export ORACLE_HOME=<valid_value>
$ export ORACLE_SID=<valid_value>
$ export PATH=<valid_value>
8. Invoke SQL Plus as the sysdba user:

$ ${ORACLE_HOME}/bin/sqlplus/ as sysdba
Note: If you are using the Oracle Database 12c, then invoke SQL Plus as /nolog user.

9. Connect to the database:

SQL> connect username/password as sysdba


Where, username and password are your database credentials.

10. Run the SQL script :

SQL> @testds_oracle.sql
This script creates a user called DBTESTER with the password that you have provided. It
grants the user the rights to create sessions, tables, and so on. It then connects to the
database as this user and creates three tables: EMPLOYEE, WLS_CATALOG_ITEMS,
and WLS_CLIENT_INFO. Finally, it inserts rows into those tables and exits.
Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

Start WebLogic Server


To start the Administration Server:

1. Open a terminal window and navigate to the domain directory:

$ cd /u01/domains/ExampleDomain/
2. In the domain directory, enter the command:

$./startWebLogic.sh
3. When prompted, enter the credentials of the domain administrator.
4. Examine the terminal output and wait for the Administration Server to reach
the RUNNING state.

<SEP 16, 2018 9:57:34,722 AM EDT> <Notice>


<WebLogicServer> <BEA-000360> <The server started in
RUNNING mode.>
<SEP 16, 2018 9:57:34,817 AM EDT> <Notice>
<WebLogicServer> <BEA-000365> <Server state changed to
RUNNING.>

Configure a JDBC Data Source


To configure a JDBC data source using the WebLogic Server Administration Console:

1. After the Administration Server is up and running, access the WebLogic Server
Administration Console. Open a web browser and enter the Console's URL.

http://localhost:7001/console
Optionally, specify the host name and port of your domain's Administration Server in
place of localhost:7001 .

2. On the Welcome screen, enter the domain administrator credentials, and then click Login.
3. In the Change Center, click Lock & Edit.
Note: To create a data source, or change anything in the domain configuration, you must
first lock the domain configuration (to prevent other accounts from making changes
during your edit session) and enable an edit session.
4. In the left panel, under Domain Structure, expand Services and select Data Sources.
Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

5. On the Summary of JDBC Data Sources page, click New and select Generic Data Source.

6. On the JDBC Data Source Properties page:


o Enter the Name of the data source as myNewDS.
o Enter the JNDI Name of the data source as myNewDS.
Note: There is no requirement for the data source and JNDI names to be the same.
o Choose Oracle as the Database Type and click Next.
7. For Database Driver, select *Oracle's Driver (Thin) for Instance
connections; Versions:Any , and then click Next.
8. On the Transaction Options page, retain all default values and click Next.
9. On the Connection Properties page:

Field Value

Database Name XE (your database name may be different)

localhost (use the host name where you have configured your
Host Name
Administration Server)

Port 1521 (enter your database port)


Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

Database User
DBTESTER (this is the user defined in the SQL script)
Name

Database user's password (the password defined in the SQL script for
Password
above user)

Confirm Password Database user's password

10. Click Next.


11. On the Test Database Connection page, review the connection parameters and click Test
Configuration.
12. If the message Connection test succeeded displays, click Next.

If the test is unsuccessful, click Back and review the entries made for the data source,
correct any errors and then retry the test. If there are no errors in the entries and the test
still fails, make sure your database is running.
13. On the Select Targets page, select AdminServer as the data source target.
14. Click Finish to save the JDBC data source configuration and deploy the data source to the
AdminServer (target).
15. In the Change Center, click Activate Changes.
o The Console displays the message: All changes have been
activated. No restarts are necessary
o In the Summary of JDBC Data Sources page, the new data source, myNewDS, is now
listed in the Sources table.
16. To modify the configuration of the new data source, select the data source
name, myNewDS.
Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

17. On the Settings for myNewDS page, select Configuration and then select Connection
Pool, and scroll down to find the capacity fields and change the existing values to:

18. Click Save.


19. In the Domain Structure tree, expand Environment and select Servers.
20. In the Servers table, select AdminServer(admin).
21. To validate the configuration and target of the data source, view myNewDS in the JNDI
Tree. To view the JNDI Tree, on the Settings for AdminServer page:
o Select Configuration and then select General.
o Select View JNDI Tree.
Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

The JNDI tree opens in a new window and myNewDS appears in the JNDI tree. Other
entries in the JNDI tree of your server may vary depending on the available resources in

your server.

Test the JDBC Data Source


To test the JDBC data source with a simple web application:

1. Deploy the application testds located in the testds.war file.


o Open a new terminal window and navigate to the APP_HOME directory.

$ cd ${APP_HOME}
o Run the deploy.sh script to deploy the web application in
the testds.war file and target it to the Administration Server. This script is part
of the example application (extracted earlier) into APP_HOME directory.

$./deploy.sh -a testds -p testds.war -U username


2. In the command, -a specifies the name of the application, -p specifies the path
to testds.war file and -U specifies the Weblogic Server user name.
o After you run the command, enter the password for your WebLogic Server
Administrator user name when prompted.
o After the application is successfully deployed, you will get a message similar to:

3. >>>Deploying application testds.war to target


Adminserver. Please wait.
4.
5. Deploying application from
/tmp/downloads/JDBC/testds.war to targets Adminserver
(upload=false) ...
6.
7. .Completed the deployment of Application with status
completed
8. Current Status of your Deployment:
9. Deployment command type: deploy
Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

10. Deployment State : completed


11. Deployment Message : no message
12. >>>Application testds deployed.
13.

Exiting WebLogic Scripting Tool.


14. To verify the success of deployment, return to the Administration Console:
o Under Domain Structure, click Deployments.
o In the Deployments table, ensure that the testds application is in the Active state.

15. To use the deployed application, in another web browser, enter the host and port for the
Administration Server followed by /testds.

http://localhost:7001/testds

16. When the application opens, enter:

Field Value

Data Source Name: myNewDS

Table Name: EMPLOYEE


Name: Prathamesh Sawant
LinkedIn: https://www.linkedin.com/in/prathamesh-sawant7882

Username: Use your domain administrator's user name

Password: Use your domain administrator's password

17. Click Test Data Source.


The rows in the EMPLOYEE table are displayed below the fields. The application uses
the Data Source Name entered (myNewDS) as the JNDI name to look up the data source
from AdminServer. It then retrieves a database connection from that data source,
and executes the SQL to select all the rows in the table entered in the Table Name field
(EMPLOYEE). If you want to test the data source again, try a different table in the Table
Name field. The other two tables
are WLS_CATALOG_ITEMS and WLS_CLIENT_INFO.

You might also like