Following is a JACL (wsadmin - scripting tool) script used to create a data source and test the connection. This script:
#AWE -- Set up XA DB2 data sources, both 5.0 and 4.0 #UPDATE THESE VALUES: #The classpath that will be used by your database driver set driverClassPath "/QIBM/UserData/Java400/ext/db2_classes.jar" set server "server1" #Users and passwords.. set defaultUser1 "dbuser1" set defaultPassword1 "dbpwd1" set aliasName "alias1" set databaseName1 "localhost" set databaseName2 "localhost" #END OF UPDATES puts "Add an alias alias1" set cell [$AdminControl getCell] set sec [$AdminConfig getid /Cell:$cell/Security:/] #--------------------------------------------------------- # Create a JAASAuthData object for component-managed authentication #--------------------------------------------------------- puts "create JAASAuthData object for alias1" set alias_attr [list alias $aliasName] set desc_attr [list description "Alias 1"] set userid_attr [list userId $defaultUser1] set password_attr [list password $defaultPassword1] set attrs [list $alias_attr $desc_attr $userid_attr $password_attr] set authdata [$AdminConfig create JAASAuthData $sec $attrs] $AdminConfig save puts "Installing DB2 datasource for XA" puts "Finding the old JDBCProvider.." #Remove the old jdbc provider... set jps [$AdminConfig list JDBCProvider] foreach jp $jps { set jpname [lindex [lindex [$AdminConfig show $jp {name}] 0] 1] if {($jpname == "FVTProvider")} { puts "Removing old JDBC Provider" $AdminConfig remove $jp $AdminConfig save } } #Get the server name... puts "Finding the server $server" set servlist [$AdminConfig list Server] set servsize [llength $servlist] foreach srvr $servlist { set sname [lindex [lindex [$AdminConfig show $srvr {name}] 0] 1] if {($sname == $server)} { puts "Found server $srvr" set serv $srvr } } puts "Finding the Resource Adapter" set rsadapter [$AdminConfig list J2CResourceAdapter $serv] #Now create a JDBC Provider for the 5.0 data sources puts "Creating the provider for com.ibm.db2.jdbc.app.DB2StdXADataSource" set attrs1 [subst {{classpath $driverClassPath} {implementationClassName com.ibm.db2.jdbc.app.DB2StdXADataSource} {name "FVTProvider2"} {description "DB2 UDB for iSeries JDBC Provider"}}] set provider1 [$AdminConfig create JDBCProvider $serv $attrs1] #Create the first data source puts "Creating the datasource fvtDS_1" set attrs2 [subst {{name fvtDS_1} {description "FVT DataSource 1"}}] set ds1 [$AdminConfig create DataSource $provider1 $attrs2] #Set the properties for the data source. set propSet1 [$AdminConfig create J2EEResourcePropertySet $ds1 {}] set attrs3 [subst {{name databaseName} {type java.lang.String} {value $databaseName1}}] $AdminConfig create J2EEResourceProperty $propSet1 $attrs3 set attrs10 [subst {{jndiName jdbc/fvtDS_1} {statementCacheSize 10} {datasourceHelperClassname com.ibm.websphere.rsadapter.DB2DataStoreHelper} {relationalResourceAdapter $rsadapter} {authMechanismPreference "BASIC_PASSWORD"} {authDataAlias $aliasName}}] $AdminConfig modify $ds1 $attrs10 #Create the connection pool object... $AdminConfig create ConnectionPool $ds1 {{connectionTimeout 1000} {maxConnections 30} {minConnections 1} {agedTimeout 1000} {reapTime 2000} {unusedTimeout 3000} } #Now lets create the 4.0 data sources.. puts "Creating the 4.0 datasource fvtDS_3" set ds3 [$AdminConfig create WAS40DataSource $provider1 {{name fvtDS_3} {description "FVT 4.0 DataSource"}}] #Set the properties on the data source set propSet3 [$AdminConfig create J2EEResourcePropertySet $ds3 {}] #These attributes should be the same as fvtDS_1 set attrs4 [subst {{name user} {type java.lang.String} {value $defaultUser1}}] set attrs5 [subst {{name password} {type java.lang.String} {value $defaultPassword1}}] $AdminConfig create J2EEResourceProperty $propSet3 $attrs3 $AdminConfig create J2EEResourceProperty $propSet3 $attrs4 $AdminConfig create J2EEResourceProperty $propSet3 $attrs5 set attrs10 [subst {{jndiName jdbc/fvtDS_3} {databaseName $databaseName1}}] $AdminConfig modify $ds3 $attrs10 $AdminConfig create WAS40ConnectionPool $ds3 {{orphanTimeout 3000} {connectionTimeout 1000} {minimumPoolSize 1} {maximumPoolSize 10} {idleTimeout 2000}} #Now we will add a connection factory for the CMPs.. puts "Creating the CMP Connector Factory for fvtDS_1" set attrs12 [subst {{name "FVT DS 1_CF"} {authMechanismPreference BASIC_PASSWORD} {cmpDatasource $ds1} {authDataAlias $aliasName}}] set cf1 [$AdminConfig create CMPConnectorFactory $rsadapter $attrs12] #Set the properties for the data source. $AdminConfig create MappingModule $cf1 {{mappingConfigAlias "DefaultPrincipalMapping"} {authDataAlias "alias1"}} $AdminConfig save
Note: Example may be wrapped for display purposes.