copenndthagen
copenndthagen

Reputation: 50742

WLST command to update JDBC DataSource URL

I use the Weblogic Console to navigate to Data Sources and update the URL in my Data Sources. Is there any way by which I can do the same using WLST command. I need to update from command.

I just need to update the URL of my Data Source.

Upvotes: 1

Views: 8124

Answers (2)

Dunderklumpen
Dunderklumpen

Reputation: 1874

We do this via a wlst script in a slightly different fashion:

edit()

# set url and remove the target so we can redeploy without 
# restarting managed server
startEdit()

cd("/JDBCSystemResources/"+dsName)
targets = get('Targets')

# set an array ob empty objects to the datasource's targets
set('Targets',jarray.array([], ObjectName))

cd("JDBCResource/"+dsName+"/JDBCDriverParams/"+dsName)
set("Url", dbURL)

save()
activate()

# reset thge original targets so the datasource will be refreshed
startEdit()
cd("/JDBCSystemResources/"+dsName)
set('Targets', targets)

save()
activate()

The thing I found I needed to do here was that changing the URL on the datasource object does not redeploy it to any managed managed servers that the datasource is attached to. If you use managed servers, you either have to set targets to empty, save the datasource, then set the original targets, save again. This redeploys the datasource to any managed servers.

The only other alternative is to restart any managed server.

If your admin server is also your hosting server (ie no managed servers) you do not need to worry about any of the messing about with targets in the script above.

Upvotes: 4

PavanDevarakonda
PavanDevarakonda

Reputation: 629

Yes it is possible with WLST online commands. Let us say 'myds' is the sample datasource name, which you wish to change the URL. You must be in the edit tree for the changes. The URL is available in the JDBCDriverParams mbean tree, so navigate to that mbean then use set the attribute with setUrl command for change the current value with new value. After changes use save(), activate() commands.

`

     1. cd('/JDBCSystemResources/myds/JDBCResource/myds')
     2. cd('JDBCDriverParams/myds')
     3. ls()
     4. cmo.setUrl('new.db.url:port')

` for more details you can ref some WLST datasource configuration scripts.

Upvotes: 0

Related Questions