How to find the database name using wsadmin scripting? - Websphere

This is a discussion on How to find the database name using wsadmin scripting? - Websphere ; Hi, Someone please let me know how to find the database name from a datasource using wsadmin(Jython) scripts. AdminConfig.list('DataSource') above command lists all datasources, how do I take a particular datasource and find the database name in it. Any help ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: How to find the database name using wsadmin scripting?

  1. How to find the database name using wsadmin scripting?

    Hi,

    Someone please let me know how to find the database name from a datasource using wsadmin(Jython) scripts.

    AdminConfig.list('DataSource')

    above command lists all datasources, how do I take a particular datasource and find the database name in it.

    Any help would be greatly appreciated.

    Thanks,
    cnuwas

  2. Re: How to find the database name using wsadmin scripting?

    This works for me:

    dsList = AdminConfig.list('DataSource').splitlines()
    for ds in dsList:
    ___# Get the database name for this data source
    ___try: propSet = AdminConfig.showAttribute(ds, 'propertySet')
    ___except AdminException, why:
    ______print 'Error getting propertySet:'
    ______print why
    ___else:
    ______propList = AdminConfig.list('J2EEResourceProperty', propSet).splitlines()
    ______for prop in propList:
    _________if AdminConfig.showAttribute(prop, 'name') == 'databaseName':
    ____________dbName = AdminConfig.showAttribute(prop, 'value')

    I replaced leading spaces with underscores to preserve indentation in the forum.

  3. Re: How to find the database name using wsadmin scripting?

    Excellent, Thanks a lot Jorg.
    I made few changes and it worked. This gave me new direction to write other datasource related stuffs.
    I have several doubts in wsadmin scripts which I would like to post later.
    Is there any rebooks or books to learn wsadmin(jython) scripts from scratch.
    I thank and really appreciate your help.

  4. Re: How to find the database name using wsadmin scripting?

    I'm not aware of any books on wsadmin jython scripting. The infocenter has a lot of good examples of jython scripting. Use the search window (i.e., for "data source") and look in the results for topics containing "scripting".

    The infocenter for WAS 6.1 is at
    http://publib.boulder.ibm.com/infoce...elcome_nd.html

    WAS 7 infocenter is at
    http://publib.boulder.ibm.com/infoce...elcome_nd.html

+ Reply to Thread