I wanted to retreive all the information from weblogic datasources using WLST such as:
- Name
- JNDI Name
- Connection Pool parameters:
- URL
- Driver Class Name
- Properties passed to the JDBC Driver
- SetStreamAsBlob
 
- Initial Capacity
- Maximum Capacity
I’ve written a script to perform this task.
How to use this script:
<MIDDLEWARE_HOME>/soa/common/bin/wlst.sh bring_datasources.py <ENV> <DOMAIN>
#miguel.ortiz
import sys,os,re
environment = sys.argv[1]
domain = sys.argv[2]
hostUser = 'READONLY_USER'
hostPass = 'readonly_pass'
# you need to provide two parameters, environment and domain
if environment == '' or domain == '' :
        print 'este script requiere (2) parametros, Ambiente y Dominio'
# if the environment is QAM
if environment == 'QAM' :
        hostIP = '172.x.x.x'
        if domain == 'SYNC':
                hostPort = '8001'
        if domain == 'ASYNC':
                hostPort = '8002'
        if domain == 'RSYNC':
                hostPort = '8003'
# If my environment is Production
if environment == 'PROD' :
        hostIP = '172.x.x.x'
        if domain == 'SYNC':
                hostPort = '8001'
        if domain == 'ASYNC':
                hostPort = '8002'
        if domain == 'RSYNC':
                hostPort = '8003'
dsCounter = 0
# Connect to the host
connect( hostUser , hostPass , 't3://' + hostIP + ':' + hostPort )
# get all JDBC Properties
allJDBCResources = cmo.getJDBCSystemResources()
for jdbcResource in allJDBCResources:
        dsCounter +=1
        dsname = jdbcResource.getName()
        dsResource = jdbcResource.getJDBCResource()
        dsJNDIname = dsResource.getJDBCDataSourceParams().getJNDINames()#[0]
        dsInitialCap = dsResource.getJDBCConnectionPoolParams().getInitialCapacity()
        dsMaxCap = dsResource.getJDBCConnectionPoolParams().getMaxCapacity()
        dsParams = dsResource.getJDBCDataSourceParams()
        dsDriver = dsResource.getJDBCDriverParams().getDriverName()
        conn =  dsResource.getJDBCDriverParams().getUrl()
        test = dsResource.getJDBCDriverParams().getProperties()
        test1 = dsResource.getJDBCConnectionPoolParams()
        user = ''
        readTimeOut = ''
        conTimeOut = ''
        streamAsBlob = ''
       
        redirect('file','false')	
	try :
	 	user = get("/JDBCSystemResources/"+ dsname +"/Resource/" + dsname + "/JDBCDriverParams/" + dsname + "/Properties/" + dsname + "/Properties/user/Value")
	 	readTimeOut = get("/JDBCSystemResources/"+ dsname +"/Resource/" + dsname + "/JDBCDriverParams/" + dsname + "/Properties/" + dsname + "/Properties/oracle.jdbc.ReadTimeout/Value")
	 	conTimeOut = get("/JDBCSystemResources/"+ dsname +"/Resource/" + dsname + "/JDBCDriverParams/" + dsname + "/Properties/" + dsname + "/Properties/oracle.net.CONNECT_TIMEOUT/Value")
	 	streamAsBlob = get("/JDBCSystemResources/"+ dsname +"/Resource/" + dsname + "/JDBCDriverParams/" + dsname + "/Properties/" + dsname + "/Properties/SendStreamAsBlob/Value")
	except WLSTException:
		# omitimos errores por la no existencia de las propiedades buscadas con ls()
		pass
	stopRedirect()	
	print 'datasource.name.' + str(dsCounter) +'=' + str(dsname)
	print 'datasource.jndiname.' + str(dsCounter) + '=' + str(dsJNDIname)
	print 'datasource.driver.class.' + str(dsCounter) + '=' + dsDriver
	print 'datasource.url.' + str(dsCounter) + '=' + conn
	print 'datasource.readTimeout.' + str(dsCounter) + '=' + readTimeOut 
	print 'datasource.connectionTimeout.' + str(dsCounter) + '=' + conTimeOut 
	print 'datasource.username.' + str(dsCounter) + '=' + user
	print 'datasource.password.' + str(dsCounter) + '=' 
	print 'datasource.initialCapacity.' + str(dsCounter) + '=' + str(dsInitialCap)
	print 'datasource.maxCapacity.' + str(dsCounter) + '=' + str(dsMaxCap)
	print 'datasource.target.' + str(dsCounter) + '=' + target
	if not streamAsBlob :
		getStreamAsBlob = 'false'
	else :
		print '#datasource.sendStreamAsBlob.' + str(dsCounter) + '=' + streamAsBlob
	print '\n'
- The output of the script was adjusted to match the input of another script for datasource creation, adjust it to your needs.
 
					 
												
