solidDB Help : Samples : J2EE sample application for WebSphere Application Studio
  
J2EE sample application for WebSphere Application Studio
Note This sample has been tested with IBM WebSphere Application Server V7 and IBM WebSphere Application Studio V5.1.1. The sample might not work with later versions.
This sample demonstrates how to install and use a J2EE sample application by using the solidDB JDBC driver with IBM WebSphere Application Server and with IBM WebSphere Application Studio. For more information about compatibility between IBM WebSphere Application Server and solidDB, see IBM WebSphere Application Server compatibility.
The files for the sample are located in the soliddb-installdir\samples\websphere directory. For general information about running the samples, see Samples.
The sample application contains an EJB (a sessionbean) that can make connections to a solidDB server by using the solidDB implementation of a connection pooling data source class named SolidConnectionPoolDataSource.
The sample also contains an application client that calls the EJB. The application fetches all table names from the given database server and prints them out to the console.
The sample includes the following components:
SolidTestEAR.ear: Enterprise application package that contains the following jar files and all needed meta information:
SolidTest.jar: The source, compiled classes and the meta information of the EJB part of the application
SolidTestClientProject.jar: The corresponding data of the client part of the application
You can explore the contents of the package by using the Java jar utility.
SolidSetup.py: Creation, installation, and maintenance scripts for the sample
The sample assumes that you already have a solidDB server defined.
The sample can be used with either WebSphere Application Server V7 or WebSphere Application Studio V5.1.1.
Running the sample with IBM WebSphere Application Server V7
Complete the following steps to prepare your environment and run the sample by using IBM WebSphere Application Server V7:
1 Ensure that your machine has a working installation of WebSphere Application Server (WAS) V7 that includes the following components:
WAS 'wsadmin' scripting tool. The tool is located in the WAS install_root\bin directory, for example:
C:\Program Files\IBM\WebSphere\AppServer\bin\wsadmin.bat
WAS Administrative Console, which is accessed from the following URL:
http://hostname:9060/ibm/console
WebSphere Application Client Tool 'launchCLient': The tool is located in the WebSphere Application Client install_root\bin directory, for example:
C:\Program Files\IBM\WebSphere\AppClient\bin\launchClient.bat
2 Start the solidDB server.
3 Start WAS.
4 Create solidDB JDBC providers and solidDB data sources by running the following command:
wsadmin -f SolidSetup.py configure
You are prompted to provide details of the solidDB server configuration. In Windows environments, if you have installed solidDB using the default settings, you can use the default values that the command suggests.
Two solidDB providers and their respective data stores are created, one that supports the two phase commit JTA protocol (SolidXADataSource) and one that does not (SolidDataSource).
Note To remove the solidDB providers, you can execute the following command:
wsadmin -f SolidSetup.py cleanup
5 Test the connection between solidDB and WAS by performing the following steps in the WAS Administrative Console.
a In the left pane, navigate to Resources > JDBC > Data sources.
b In the ‘Data sources’ pane, locate the following solidDB data sources:
SolidDataSource
SolidXADataSource
c Test the connection to each of the data sources by completing the following steps:
i Select the data source.
ii Click the Test Connection button.
Note The solidDB server must be running for the connection to succeed.
Your solidDB data sources are now ready for use with WebSphere applications.
6 Install the SolidTestEAR.ear application by running the following command:
wsadmin -f SolidSetup.py install
Note To remove the application, you can execute the following command:
wsadmin -f SolidSetup.py uninstall
7 Start the SolidTestEAR.ear application by completing the following steps in the WAS Administration Console:
a In the left pane, navigate to Applications > Application Types > WebSphere enterprise applications.
b Select SolidTestEAR, and click the Start button.
The application status should now show as Started.
8 Run the SolidTestEAR.ear application by executing the following command in the solidDB samples/websphere directory:
launchClient SolidTestEAR.ear
Running the sample with IBM WebSphere Application Studio V5.1.1
Complete the following steps to prepare your environment and run the sample by using IBM WebSphere Application Studio V5.1.1:
1 Start the solidDB server.
2 Define the SolidTest enterprise bean properties by completing the following steps:
a Import the SolidTestEAR.ear file to the WebSphere Studio Application Developer (WSAD) workspace by clicking File > Import.
b From the WSAD navigator, select J2EE Perspective, expand the EJB Modules sub-tree, right-click the SolidTest module, and then click Properties.
c In the ‘Properties’ window, click Java Build Path and then click the ‘Libraries’ tab.
d Click Add External JARs and add the solidDB JDBC driver jar file from the solidDB installation (jdbc\SolidDriver2.0.jar).
You have defined the SolidTest enterprise bean properties.
3 Define the server configuration for the test application by completing the following steps:
a From the WSAD navigator, select Server Perspective.
b In the ‘Server Configuration’ pane right-click Servers and select New > Server and Server Configuration.
c In the 'Create a New Server and Server Configuration' window, type SolidTestServer in the Server name field.
d In the 'Server type:' tree, click WebSphere version 5.0 > Test Environment and click Finish.
You have created a server and a configuration for the test application.
4 Create a new JDBC provider configuration for the solidDB JDBC driver by completing the following steps:
a In the ‘Server Configuration’ pane, expand the Server tree, and double-click SolidTestServer.
A new server configuration pane opens in the workspace.
b Click the 'Data source' tab in the ‘SolidTestServer’ pane, and in the 'Server Settings' context, click Add in the 'JDBC Provider’ list.
c Complete the following fields and click Next:
Database type: Select User-defined
JDBC provider type: Select User-defined JDBC provider
d Complete the following fields and click Finish:
Name: Type solidDB JDBC Driver
Implementation class name: Type solid.jdbc.SolidConnectionPoolDataSource. This is the class name of the pooled data source implementation of solidDB JDBC driver.
Classpath: Type the exact paths to the solidDB JDBC driver jar file (for example C:\Solid\jdbc\SolidDriver2.0.jar) and the data store helper archive (for example C:\Solid\jdbc\SolidDataStoreHelper.jar).
You have created a new JDBC provider configuration for solidDB JDBC driver.
5 Create a new JDBC data source by completing the following steps:
a Select solidDB JDBC Driver from the JDBC provider list and click Add in the Data source list.
b Select User-defined JDBC provider and Version 5.0 data source and click Next.
c Complete the following fields, and then click Finish:
Name: Type SolidDataSource
JNDI Name: type jdbc/SolidDataSource
Data source helper classname: Type com.ibm.websphere.rsadapter.SolidDataStoreHelper
Container managed persistence (CMP): Deselect the check box.
You have created a new JDBC data source.
6 Add a new resource property for the ‘SolidDataSource’ resource by clicking Add next to the data source property list, and completing the types and values for the following property names:
 
Property
Type
Value
URL
java.lang.String
jdbc:solid://host:port
where host and port are the host name and port of your solidDB server
user
java.lang.String
valid user name for your solidDB server
password
java.lang.String
password for the user name
7 In the EJB tab of the ‘SolidTestServer’ pane, select SolidDataSource in the Default data source field.
8 Save the ‘SolidTestServer’ configuration and close the corresponding pane.
9 In the 'J2EE Hierarchy' pane right-click the SolidTest EJB and select Run on Server from the menu.
10 From the 'Server Selection' window, select SolidTestServer from the server list and click Next.
11 Select the Deploy EJB beans check box and click Finish.
The test server containing the ‘SolidTest’ EJB should now start.
12 In the 'J2EE Hierarchy' pane, select SolidTestClientProject from the 'Application Client Modules' subtree.
13 From the Run menu select Run.
14 Create a new client application launcher by selecting WebSphere v5 Application Client and clicking New.
15 Complete the following fields and then click Run to launch the client application:
Name: Type SolidTestClientLauncher
Enterprise application: Select SolidTestEAR
Client application: Select SolidTestClientProject
Go up to
Samples