It was posted in oracle forum about how to test data source from wlst command line.
The script is fine and bit clear. The only concern is the output of testpool() method. It will print None unless we fetch the query and print the result. If we use default JDBC package and query “SELECT count( * ) FROM `systables`” to fetch data from default SYSTABLE the same result will be printed, unless we use fetchall() method.
Please try the below script and compare.
Save this file by any name with extention .py and exicute from wlst.
The script is fine and bit clear. The only concern is the output of testpool() method. It will print None unless we fetch the query and print the result. If we use default JDBC package and query “SELECT count( * ) FROM `systables`” to fetch data from default SYSTABLE the same result will be printed, unless we use fetchall() method.
Please try the below script and compare.
#!/bin/python ''' Python Version - 2.* @author : Jaydeb Chakraborty ?? Use WLST to test Data Source via python script ''' from weblogic.security.internal import * from weblogic.security.internal.encryption import * from com.ziclix.python.sql import zxJDBC from java.io import FileInputStream from xml.dom import minidom # Please put the correct path of DataSource Config xml. doc = minidom.parse('d:/bea/Weblogic1033/user_projects/domains/weblogic1033_domain/config/jdbc/JDBC_Data_Source-0-3407-jdbc.xml') s = doc.childNodes t = s[0] JDBC_DS_NAME = t.childNodes[1].firstChild.data JDBC_URL = t.childNodes[3].childNodes[1].firstChild.data JDBC_DRIVER = t.childNodes[3].childNodes[3].firstChild.data JDBC_USER_NAME = t.childNodes[3].childNodes[5].childNodes[1].childNodes[3].firstChild.data ENCRP_PASSWORD = t.childNodes[3].childNodes[7].firstChild.data #Connect AdminServer where connection pool has been targeted #We can keep these parameters in properties file to avoide hard coding connect('weblogic','weblogic123','t3://localhost:7001') #Get password of connectionpool encryptionService = SerializedSystemIni.getEncryptionService(".") clearOrEncryptService = ClearOrEncryptedService(encryptionService) pwd = ENCRP_PASSWORD # Remove unnecessary escape characters preppwd = pwd.replace("\\", "") # Decrypt the password psd=clearOrEncryptService.decrypt(preppwd) #Connect with Database con = zxJDBC.connect(JDBC_URL, JDBC_USER_NAME, psd, JDBC_DRIVER) cursor = con.cursor() result1=cursor.execute("SELECT count( * ) FROM `systables` WHERE 1") result=cursor.fetchall() #print number of row exist print(result) # Print the output of "result1", the exact result you will received as you get exicuting testPool() if result == None: print("Check Table") else: print("The above number of row has been fetched")
Save this file by any name with extention .py and exicute from wlst.