Date Created: Tue 19-Feb-2008

Related Document Categories:

Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/



    WebSphere JDBC JACL script to configure the ORACLE_JDBC_DRIVER_PATH environment variable.

    Configuring you Oracle JDBC Path with JACL.

    If your application server requires to talk to a an Oracle Database via JDBC then you will need to find a standard way to refer to the Oracle JDBC classes.

    As everyone knows I am all about automation and repeatability. Using standard build script saves time, and money for all. It also removed human error.

    If you oracle client install and JDBC lib path are something like /ora/app/oracle<inst>/product/9.2/jdbc/lib you may wish to build script that will automatically confuigure a standard\build process for adding the Oracle JDBC path to the ORACLE_JDBC_DRIVER_PATH WebSphere variable.


    create_jdbc_path.jacl

    #--------------------------------------------
    # Read and load the input file
    #--------------------------------------------

    proc loadProperties {propFileName} {
    java::import java.io.FileInputStream
    java::import java.util.Properties

    set fileprop [java::new Properties]
    set fileStream [java::new FileInputStream $propFileName]

    $fileprop load $fileStream
    return $fileprop
    }

    #-----------------------------------------------------
    # method to create new was variable
    #----------------------------------------------------
    proc CreateWasVar { varName varVal varDesc nodeVarMapID } {
    global AdminConfig
    set nameAtt [list symbolicName $varName]
    set valAtt [list value $varVal]
    set descAtt [list description $varDesc]
    set newAttributes [list $nameAtt $valAtt $descAtt]

    puts "Creating : $newAttributes"
    $AdminConfig create VariableSubstitutionEntry $nodeVarMapID $newAttributes
    }

    #-----------------------------------------------------
    # method to modify new was variable
    #----------------------------------------------------
    proc ModifyWasVar { varID varVal varDesc } {
    global AdminConfig
    $AdminConfig modify $varID [list [list value $varVal] [list description $varDesc]]
    }

    #--------------------------------------------------------------
    # load input.props file
    #--------------------------------------------------------------
    set ora_props [loadProperties ora-specific-input.props]

    #-----------------------------------------------------
    # main program loops thru nodes to set the value
    #-----------------------------------------------------

    for {set nodeIndex 1} {[string length [set nodeName [$ora_props getProperty com.ora.was.node$nodeIndex.name]]] != 0} {incr nodeIndex} {
    puts "-------------------------------------"
    puts "Info :- Working on Node: $nodeName"
    puts "-------------------------------------"
    set nodeID [$AdminConfig getid /Node:$nodeName]
    if { [llength $nodeID] == 0 } {
    puts "ERROR :- Node \"$nodeName\" not found in current was config"
    continue
    }
    set nodeVarMap [$AdminConfig getid /Node:$nodeName/VariableMap:/]

    if { [llength $nodeVarMap] == 0} {
    puts "NO node variable map is created"
    puts "Creating variable map for the node : $nodeName"
    set nodeParent [$AdminConfig getid /Node:$nodeName]
    set nodeVarMap [$AdminConfig create VariableMap $nodeParent{}]
    puts "Variable Map created"
    puts "nodeMap : $nodeVarMap"
    } else {
    puts "Current node variable map available: $nodeVarMap"
    }
    set entries [lindex [$AdminConfig showAttribute $nodeVarMap entries] 0]

    for {set vIndex 1} {[string length [set variableName [$ora_props getProperty com.ora.was.variable$vIndex.name]]] != 0} {incr vIndex} {
    set foundEntry false
    puts "-------------------------------------"
    puts "Looking for variable: $variableName"
    if {[llength $entries"] != 0} {
    puts "Info: - Check if the variable is already there"
    foreach entry $entries {
    set entryName [$AdminConfig showAttribute $entry symbolicName]
    if { $entryName == $variableName } {
    set entryValue [$AdminConfig showAttribute $entry value]
    puts "Variable found : name: $entryName $entryValue"
    set foundEntry true
    break
    }
    }
    }
    set varVal [$ora_props getProperty $variableName]
    if {[llength $varVal] == 0 } {
    puts "WARN :- $variableName is not provided or provided as blank"
    }
    set varDesc "node level variables"

    if {![file exists $varVal]} {
    puts "ERROR: The location is wrong: $varDesc!";
    } else {

    # now create/modify the was variable
    if { $foundEntry == "false" } {
    puts "Creating variable : $variableName"
    CreateWasVar $variableName $varVal $varDesc $nodeVarMap

    } else {
    puts "Modifying variable : $variableName"
    ModifyWasVar $entry $varVal $varDesc

    }
    }
    }
    puts "Saving the work"
    puts "-------------------------------------"

    $AdminConfig save
    }




    -----------------------------------------------------------------------------------------------
    input props file
    ---------------------------------------------------------------------------------------------



    ora-specific-input.props


    #------------------------------------------------
    # Node name(s)
    #------------------------------------------------
    com.ora.was.node1.name=<websphere_nodename>
    #-------------------------------------------------
    # WebSphere Environment Variable
    #-------------------------------------------------
    com.ora.was.variable1.name=ORACLE_JDBC_DRIVER_PATH

    #------------------------------------------------
    # values of the above variables
    #------------------------------------------------
    ORACLE_JDBC_DRIVER_PATH=/ora/app/oracle<inst>/product/9.2/jdbc/lib

    Get my WebSphere Application Server course here >> http://www.themiddlewareshop.com/products/


Steve Robinson - IBM Champion 2013

About Me

Steve Robinson has been working in IT for over 20 years and has provided solutions for many large-enterprise corporate companies across the world. Steve specialises in Java and Middleware.

In January 2013, I was awarded the prestigous 'IBM Champion' accolade.


Read my books?

IBM WebSphere Application Server 8.0 Administration Guide

IBM WebSphere Application Server 8.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Application Server 7.0 Administration Guide

WebSphere Categories

Other Categories