Hi,

Jay SenSharma

Jay SenSharma

Here is a Simple WLST script which we can run to check whether the DataSource is running properly or not,. This WLSt script can also be set as part of a Scheduled CRON job in Unix based Operating Systems .. using mailx tool so that we will keep on getting E-Mails about the status of the DataSource:

NOTE: Before running the Below script we need to enable “Test Connect On Reserve” and provide the “Test Table Name”  name for the DataSource.

NOTE: Make sure that in the connect()  function you are passing the  IP Address/HostName  of the Server where the DataSource is actually targeted. In the below sample I targeted my DataSource to the AdminServer that’s why i am passing the AdminServer URL in the thrid argument of the   connect()  function.

TestDS.py  (Beware in WLST scripts alignment is very important)

connect('weblogic', 'weblogic', 't3://localhost:7001')
serverRuntime()
dsMBeans = cmo.getJDBCServiceRuntime().getJDBCDataSourceRuntimeMBeans()
ds_name = "myDataSourceName"
for ds in dsMBeans:
        if (ds_name == ds.getName()):
                  print 'DS name is: '+ds.getName()
                  print 'State is ' +ds.getState()
                  print ds.testPool()

Please run the “. ./setWLSEnv.sh” before running the above WLST
java weblogic.WLST   /my/scripts/locations/TestDS.py

As an alternative you can also use “weblogic.Admin” utility to test the DataSources:
Example:

java weblogic.Admin -username weblogic -password weblogic -url t3://HostName:9001 TEST_POOL  TestDataSource

.

.

Thanks

Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.