Search code examples
jdbcweblogicmonitoringconnection-poolingwlst

Weblogic Monitoring Data Source (Jdbc Connection Pool)


I am a beginner in weblogic. I am writing this script in wlst that monitors the number of connections currently made from a jdbc connection pool belonging to a data source.

Here is my understanding of how the admin console works. Jdbc service needs to be defined first and then assigned to a server (or servers) . Once the changes are activated , an instance of the jdbc service gets created on the server.

Following is the wlst jython code snippet that i have written (using the java docs):

domainRuntime()
servers=domainRuntimeService.getServerRuntimes()

for server in servers:
 jdbcDSrcs=server.getJDBCServiceRuntime().getJDBCDataSourceRuntimeMBeans()
 print 'Domain Name         #', cmo.getName()
 print 'Server Name         #', server.getName()
 for jdbaDSrc in jdbcDSrcs:
    print 'Data Source Name #', jdbaDSrc.getName()
    print 'Curr Connc Count #', jdbaDSrc.getActiveConnectionsCurrentCount()

Could you please critique the logic and code ?

(I do not have access to test environment yet. Hence have not been able to run it. I am pretty much coding in the dark)

Also a lot of examples in the online forums have the following lines:

pools= adminHome.getMBeansByType('JDBCConnectionPoolRuntime')
for pool in pools:
  ......

Whats the difference between the code that I have written and the one above?


Solution

  • Both of these WLST calls do the same thing but the important bit of info is that JDBCConnectionPoolRuntimeMBean has been deprecated and replaced by getJDBCDataSourceRuntimeMBeans() as of Weblogic version 9. See that mentioned here:

    http://docs.oracle.com/cd/E21764_01/apirefs.1111/e13945/weblogic/management/runtime/JDBCConnectionPoolRuntimeMBean.html

    You should prefer the use of your original example:

    jdbcDSrcs=server.getJDBCServiceRuntime().getJDBCDataSourceRuntimeMBeans()
    

    Unless you are on an even older version of Weblogic. Syntactically the first example looks correct, we do the same thing with 10.3.6.