### ### set_jdbc.jacl ### ### ### Create a JDBCProvider object using a template. ### ### Usage: ### ### wsadmin.sh -username user ### -password passwd ### -f set_jdbc.jacl cellname user password ### ### where user and password are login information ### for the database/schema to which you are attaching. ### ### This script sets several constants that need to be customized: ### ### Name of the new JDBCProvider object ### Name of the new DataSource object ### String to be used when searching for an appropriate template ### Path to the driver needed for this JDBCProvider ### proc jdbc {xcellName xusername xpassword xJDBCname xdatasrc xtemplate xdesc xclasspath xauthDataAlias} { ### ### set up globals ### global AdminConfig ### ### Customize these for your installation ### #set xJDBCname "Acme XA DataSource" #set xdatasrc jdbc/XaDataSource #set xtemplate "Oracle JDBC Thin Driver (XA)" #set xdesc "Oracle JDBC Thin Driver (XA)" #set xclasspath /usr/local/username/lib/classes12.jar ### ### Get available JDBCProvider templates. ### #puts "Getting the JDBCProvider template whose name includes $xtemplate" set ztemplate [lindex [$AdminConfig listTemplates JDBCProvider $xtemplate] 0] puts " " puts "Using template: $ztemplate" ### ### From the list of templates returned ### Create JDBCProvider using the template ### specified in $xtemplate ### set xname_attr [list name $xJDBCname] set xdesc_attr [list description $xdesc] set xclasspath_attr [list classpath $xclasspath] set xattrs [list $xname_attr $xdesc_attr $xclasspath_attr] set zcell [$AdminConfig getid /Cell:$xcellName/] puts " " puts "Creating newJDBCProvider using $zcell $xattrs $ztemplate" set xNewJDBCProvider [$AdminConfig createUsingTemplate JDBCProvider $zcell $xattrs $ztemplate] #puts "The New JDBC Provider is: $xNewJDBCProvider" ### ### Create our datasource ### ### To set custom properties for datasource, ### run ds_custom_properties.jacl ### puts " " puts "Modifying the datasource object: name, jndiName, properties." set xds [$AdminConfig getid /JDBCProvider:$xJDBCname/DataSource:/] set xname_attr [list name $xdatasrc] #set xjndiName_attr [list jndiName $xdatasrc] set xjndiName_attr [list jndiName jdbc/XaDataSource] set xstmt_cache [list statementCacheSize 0] set xauthDataAlias_attr [list authDataAlias $xauthDataAlias] #set xmappingConfigAlias_attr [list mappingConfigAlias DefaultPrincipalMapping] set xuser_attr [list [list name user] [list value $xusername] [list type java.lang.String]] set xpassword_attr [list [list name password] [list value $xpassword] [list type java.lang.String]] set xnewprops [list $xuser_attr $xpassword_attr] set xresprops [list resourceProperties $xnewprops] set xps_attr [list propertySet [list $xresprops]] set xattrs [list $xname_attr $xjndiName_attr $xps_attr $xstmt_cache $xauthDataAlias_attr] puts " " puts "Modifying $xds datasource with $xattrs" $AdminConfig modify $xds $xattrs ### ### Modify the DataSource to give it a relational resource adapter. ### We just use the first one we find for this cell, but other ### schemes are possible. ### puts " " puts "Modifying the datasource object: relationalResourceAdapter" set xrra [lindex [$AdminConfig list J2CResourceAdapter] 0] set xrra_attr [list relationalResourceAdapter $xrra] set xattrs [list $xrra_attr] puts " " puts "Setting: $xds $xattrs" $AdminConfig modify $xds $xattrs ### ### Set Max Connections for datasources ### Set Mapping-Configuration Alias for datasources ### set t1 [$AdminConfig getid "/DataSource:$xdatasrc/"] puts $t1 $AdminConfig modify $t1 {{connectionPool {{maxConnections 40}}}} $AdminConfig modify $t1 {{mapping {{mappingConfigAlias DefaultPrincipalMapping}}}} ### ### Set URL for datasources ### # Might need to be enhanced. It is assumed that there is only one J2EEResourcePropertySet. # But there probably can only be one. I created a new J2EEResourcePropertySet. The old one was overridden by the new one. # To enhance it, just loop though all of the J2EEResourcePropertySets and modify all URLs. set rplist [$AdminConfig getid "/DataSource:$xdatasrc/J2EEResourcePropertySet:/J2EEResourceProperty:/"] foreach rp $rplist { set attrbt [$AdminConfig showAttribute $rp name] if {[string compare $attrbt "URL"] == 0} { $AdminConfig modify $rp {{value jdbc:oracle:thin:@tethys:1521:dev}} } } ### ### Update the variable map -- this JDBCProvider introduced a ### new variable: ### puts " " puts "Updating the variable map." set xvm [$AdminConfig getid /Cell:$xcellName/VariableMap:/] set xsymname [list symbolicName ORACLE_JDBC_DRIVER_PATH] set xvalue [list value $xclasspath] set xdesc [list description "Path to Oracle"] set xnew1 [list $xsymname $xvalue $xdesc] set xentries_attr [list entries [list $xnew1]] set xattrs [list $xentries_attr] puts " " puts "Setting: $xvm $xattrs" $AdminConfig modify $xvm $xattrs ### ### Save all the changes ### puts " " puts "Saving the configuration" $AdminConfig save } ### ### Main ### if { !($argc == 9) } { puts " " puts "set_jdbc.jacl " puts " " puts "Usage: wsadmin.sh -username system -password password -f set_jdbc.jacl cellname dbuser dbpassword \"JDBCname\" \"DataSourceName\" \"template\" \"desc\" classpath authDataAlias" puts " " puts "For example: " puts " " puts "wsadmin.sh -username system -password password -f set_jdbc.jacl twainNetwork wsdev3 dev \"NAPXAJDBC\" \"NAPDATASOURCE\" \"Oracle JDBC Thin Driver (XA)\" \"Oracle JDBC Thin Driver (XA)\" /usr/local/wsdev3/lib/classes12.jar twainManager/oracleAlias" puts " " } else { set cellName [lindex $argv 0] set username [lindex $argv 1] set password [lindex $argv 2] set JDBCname [lindex $argv 3] set datasrc [lindex $argv 4] set template [lindex $argv 5] set desc [lindex $argv 6] set classpath [lindex $argv 7] set authDataAlias [lindex $argv 8] jdbc $cellName $username $password $JDBCname $datasrc $template $desc $classpath $authDataAlias }