DB2 Database Configuration
The instructions below describe how to configure DB2 to work with the WebSphere
Application Server Samples.
- Create an operating system user named wsdemo with a password
of wsdemo1. Use all lower case letters when creating the
wsdemo user. The wsdemo user does not require special privileges.
- On Windows, set the wsdemo user with the following properties:
- Click Password Never Expires.
- Clear User must change password at next Logon.
- Create the SAMPLE database:
- On Windows:
- Open a command window.
- Change to the <WAS_ROOT>\bin directory.
- Invoke the following script:
DB2createSampleDB.bat db2admin db2pwd
where:
- db2admin is the DB2 Administrator's user ID.
- db2pwd is the DB2 Administrator's password.
The database script
requires that you provide the user ID and password of an account that
has database create authority.
- Shut down and restart WebSphere Application Server.
- On UNIX:
- Open a command window.
- Change to the <WAS_ROOT>/bin directory.
- Invoke the following script:
./DB2createSampleDB.sh db2admin db2pwd
where:
- db2admin is the DB2 Administrator's user ID.
- db2pwd is the DB2 Administrator's password.
The database script
requires that you provide the user ID and password of an account that
has database create authority.
- Shut down and restart WebSphere Application Server.
- On Linux:
Linux users
create a database and an alias which connects to the database using TCP/IP.
The Linux server machine and Linux client machine described in these instructions
can be the same machine.
- Set up the Linux server machine:
- From the server machine, open a command window and log on as
the DB2 administrator.
- Issue the command:
db2set DB2COMM=tcpip
- Set up the server port on which DB2 listens for incoming requests:
- From the server machine, open a command window and log on
as root user.
- Edit the /etc/services file to add the following line:
db2cdb2inst1 port_number/tcp #DB2 connection service port
where: port_number is an unused port number not already listed in the /etc/services file.
- From the server machine, configure the database to use the new service:
- Open a DB2 command window and issue the command:
UPDATE DBM CFG USING SVCENAME db2cdb2inst1
Use all lower case letters when specifying db2cdb2inst1.
- Restart DB2.
- Set up the Linux client machine:
- From the client machine, open a command window and log on as
root user.
- Edit the /etc/services file to add the following line:
db2cdb2inst1 port_number/tcp #DB2 connection service port
where: port_number is the same port number you specified in the /etc/services file on the server machine.
- From the client machine, open a DB2 command window and log on
as the DB2 administrator.
- Issue the command:
CATALOG TCPIP NODE WASNODE REMOTE hostname
SERVER db2cdb2inst1
Use
all lower case letters when specifying db2cdb2inst1.
- Open a command window.
- Change to the <WAS_ROOT>/bin directory.
- Invoke the following script:
./DB2createSampleDB.sh db2admin db2pwd
where:
- db2admin is the DB2 Administrator's user ID.
- db2pwd is the DB2 Administrator's password.
The database script
requires that you provide the user ID and password of an account that
has database create authority.
- Shut down and restart WebSphere Application Server.
- Point your browser to the WebSphere Application Server Administrative Console:
http://localhost:9090/admin.
- Update the DB2 JDBC Driver, if necessary:
- Expand Resources > JDBC Drivers and click Db2JdbcDriver.
- Modify Server Class Path to the location of the JAR file containing
the DB2 JDBC driver classes on your system:
- On Windows: Point to the db2java.zip file in the DB2_ROOT\sqllib\java
directory.
- On UNIX: Point to the db2java.zip file in the DB2_ROOT/sqllib/java12
directory.
- Click OK.
- Save your configuration
- Create the Sample DataSource Object:
- Expand Resources > JDBC Drivers > Db2JdbcDriver and select
Data Sources.
- Click New.
- Use the following values in the Property window. You can leave the remaining
values blank:
Name: |
DB2 Samples DataSource |
JNDI Name: |
jdbc/sample |
Description: |
Samples Gallery DB2 DataSource |
Category: |
Samples |
Database Name: |
SAMPLE |
Default User ID: |
wsdemo |
Default Password: |
wsdemo1 |
- Click OK.
- Save your configuration.
- Point your browser to the WebSphere Application Server Administrative Console:
http://localhost:9090/admin.
- Expand Resources > JDBC Drivers > idbJdbcDriver and
click Data Sources.
- Check the box next to Samples IDB DataSource and click Delete.
- Save your configuration.
- Shutdown and restart the WebSphere Application Server.
Run the servlet to create and configure the tables in the SAMPLE database.