How to change Datasources in WLST offline


This is the second post in a series of posts giving small examples of things you can do to create WebLogic domains using offline WLST. Use this post as a starting point.


Changing Datasources is a very common task when creating domains using a predefined template. Alternatively you can create new datasources. But this examples shows how to change a datasource used by Oracle SOA Suite. The following snippet of WLST code shows how to change the URL, Password and DB user of a datasource.


DB_URL = 'jdbc:oracle:thin:@'+DB_HOST+':'+DB_PORT+'/'+DB_SERVICE
#SOADataSource
cd('/JDBCSystemResources/SOADataSource/JdbcResource/SOADataSource/JDBCDriverParams/NO_NAME_0')
set('Url',DB_URL)
set('PasswordEncrypted',' mynewpassword')
cd('Properties/NO_NAME_0/Property/user')
set('Value', 'DEV_SOAINFRA') 



Remember to change the folder (the cd command) to the right datasource before setting the values.