Friday, 8 November 2013

Jython Script to Modify Oracle JDBC driver Path

import sys, java
import java.util as util
import java.io as javaio
import re
import time
from time import sleep

cell=AdminControl.getCell()

JDBCProvider='Oracle JDBC Driver'
JDBCCell=AdminConfig.getid('/Cell:' + cell + '/JDBCProvider:' + JDBCProvider)

print JDBCCell
counter = 0
correctOraclePath="${ORACLE_JDBC_DRIVER_PATH}/ojdbc14.jar"
providerList = JDBCCell.split("\n")
print providerList
for providerID in providerList:
if (providerID.find("Oracle JDBC Driver") != -1):
jdbcProviderId = AdminConfig.getid( '/Cell:' + cell + '/JDBCProvider:Oracle JDBC Driver/')
classpathAttribute = AdminConfig.showAttribute(jdbcProviderId, 'classpath')
if ( classpathAttribute == correctOraclePath ):

print "%-11s %s" % (" ", "The variable is already correct: " + classpathAttribute  + "  for the CELL " + cell + "\n" )
            #break
else:
print ("\n MODIFYING THE JDBC CONFIGURATION at CELL LEVEL")
print "%-11s %s" % (" ", "\n Before: " + classpathAttribute  + "  for the CELL " + cell +"\n" )
AdminConfig.modify(jdbcProviderId, [['classpath', '' ]])
AdminConfig.modify(jdbcProviderId, [['classpath', correctOraclePath ]])
classpathAttribute = AdminConfig.showAttribute(jdbcProviderId, 'classpath')
#print "After: " + classpathAttribute  + "for the " + serverlist
print "%-11s %s" % (" ", "--------------------------------------------------------------------------------------\n")
print "%-11s %s" % (" ", "\n After: " + classpathAttribute  + "  for the CELL" + cell +"\n" )
print "%-11s %s" % (" ", "--------------------------------------------------------------------------------------\n")
AdminConfig.save()
print "%-11s %s" % (" ", "----------------------------------------------------------------------------------------\n")
print "%-11s %s" % (" ", " JDBC Provider Modified Successfully Completed for the CELL" + cell + "...\n")
print "%-11s %s" % (" ", "----------------------------------------------------------------------------------------\n")

#endElse
#endFor
     

No comments:

Post a Comment