The table and data source creator provides an automated way to
test CMP enterprise beans without needing to worry about the persistence mechanism
or how to configure a data source. You can test CMP beans as easily as session
beans without having to create a data source or database tables. The table
and data source creator automatically captures the following: userid, password,
alias, host name, port, path to the JDBC drivers, whether to drop tables first
or not, and whether to create data sources only and not tables.
The following database systems are supported, with restrictions as
stated:
- Cloudscape™ v5.1 which
is included as part of WebSphere® Application Server v5.0.2 and above.
- Cloudscape v5.0 which
is included as part of WebSphere Application Server v5.0.2.
- DB2® v8.2 installed
either locally or on a remote machine. You must use the Type 4 JDBC drivers
in db2jcc.jar, and a database must exist. You must have a user ID and password
to access the database.
- DB2 v8.1 installed
either locally or on a remote machine. You must use the Type 4 JDBC drivers
in db2jcc.jar, and a database must exist. You must have a user ID and password
to access the database.
- Oracle v10g installed either locally or on a remote server. You
must use the JDBC drivers in classes12.jar, and a database must exist. You
must have a user ID and password to access the database.
- Oracle v9i installed either locally or on a remote machine. You
must use the JDBC drivers in classes12.jar , and a database must exist. You
must have a user ID and password to access the database.
- Microsoft® SQL Server 2000 installed either
locally or on a remote machine. You must use the WebSphere Connect JDBC Driver, a WebSphere branded
DataDirect Connect JDBC driver that is shipped with this product. This driver
consists of four JAR files: base.jar, sqlserver.jar, util.jar, and spy.jar
(or names similar to these). You can find a copy of these drivers in the x:\lib
directory, where x is the installation directory where WebSphere Application
Server is installed. You must have a user ID and password to access the database.
Prerequisite tasks:- Create
an enterprise application project.
- Create a Version 2.x EJB project in the enterprise
application project you just created.
Restriction: Do not set a
default server for this project. There is a known problem where this task
may not run properly if a default server is set on the project. For further
details, refer to the release notes on the topic "Problems using the Run on
Server task when a project defines a default server".
- Create
2.x CMP beans in the EJB projects that correspond to the enterprise
application project you just created.
- Generate
top-down mappings, selecting one of the following as the target database:
- Cloudscape v5.1
- Cloudscape v5.0
- DB2 v8.2
- DB2 v8.1
- Oracle v10g
- Oracle v9i
- Microsoft SQL
Server 2000
- Open the EJB Deployment Descriptor editor by completing the following
steps:
- In the Project Explorer view, expand EJB Projects folder.
- Expand your EJB project folder.
- Right-click the deployment descriptor folder and select Open.
- Verify a backend ID is specified for your EJB project by completing the
following steps:
- In the Overview page, scroll down to the WebSphere Bindings section.
- Click the Refresh button beside the Current field.
- Ensure a backend ID is specified in the Current field.
For example, DB2UDBNT_V8_1.
- Save your changes and close the deployment descriptor editor.
Note: Close the server editor before you create the tables and data sources,
or the data sources will not automatically be created.
To test your CMP beans with the table and data source creator:
- In the Project Explorer view, right-click the bean and select Run
> Run on Server. The Server Selection wizard opens.
- In the Define a New Server page, choose an existing or create a WebSphere Application Server v6.0 and then
click Next.
- In the Add and Remove projects, add the EAR project to the server and then click Next.
- In the Select Tasks page, enable the Create tables and
data sources check box and then click Finish. After clicking the Finish button, you need to wait a few moments as
the workbench runs the following events:
- generates deployment code for the EJB module
- starts the server
- adds projects to the server
- opens the Universal Test Client
- For DB2,
Oracle and Microsoft SQL Server 2000: A Connection Settings
dialog box appears. A database connection is required for creating data source
and table creation. Specify the following database connection parameters:
- In the User field, type your userid
to access the database.
- In the Password field, type your password
to access the database.
- In the Confirm password field, type your
password again.
- In the Alias field, type your database
alias.
- In the Host name field, type the host
name of the database server.
- In the Port field, type the port number
that will be used to connect to the database.
- In the Jar Files Path field, specify
the path to the database JDBC drivers.
Note: If your project has DB2, Oracle, and Microsoft SQL Server 2000 as current
backends, the connection settings dialog box will have fields for all of these
backends.
- For DB2,
Oracle and Microsoft SQL Server 2000: If you have done a top-down
mapping when creating your EJBs, the Create database_vendor tables and Drop database_vendor tables
first check boxes are pre-selected. If the tables already exist
or if you do not want to create tables, clear the Create database_vendor tables check box.
If you have done a bottom-up mapping, the Create database_vendor tables check box is by default cleared, so you can automatically
create a data source if you do not want to create tables.
- If you are performing this task again:
- For Cloudscape,
the tables are recreated but the data source remains the same.
- For DB2,
Oracle and Microsoft SQL Server 2000, the table recreation
depends on your selection for Create database_vendor tables and Drop database_vendor tables
first check boxes. If you want to keep the original tables created when
you first ran this task ensure both check boxes are clear. If you want to
drop and recreate the tables and delete your original tables, enable both
check boxes.
- After filling-out the Connection Settings dialog box, click Create to
start the table and data source creation.
- For each backend defined in the EJB project, the Table and Data
Source Creator dialog box reports the following details:
- The project name of the EJB project
- The database vendor
- The backend ID used
- The data source creation status: Indicates whether a data source
is added to the EJB project.
- The table creation status: If the status of the table creation
is not successful, refer to the list of operations performed for table creation
to identify the problem.
- The list of operations performed for table creation: Contains a
list of the SQL operations and any exceptions thrown when performing the table
creation.
- (Optional) If you want to verify the creation
of the data source, complete the following:
- For WebSphere Application
server v5.x, you can open the server editor and see that the data source and
resource properties were created.
- For WebSphere Application
Server v6.x, you can open the application deployment descriptor or the WebSphere administrative
console to see that the data source and resource properties were created.
- (Optional) Use the Universal test client to test the CMP bean.