views:

308

answers:

2

I was Wondering if there is anyway of suspending / resuming weblogic 10 jdbc datasources via the command line. I am aware that i can do this in the admin console, but because our app has many different datasources it is a bit of a pain.

The reason behind this is that our testers are doing error flow tests and have to simulate the db going down. Ideally i would like to give then a bat file for suspending all datasources and another one for resuming all datasources.

Any ideas?

Thanks

+1  A: 

You can use the WLST scripting to do that. From the command line, run $BEA_HOME/wlserver10.0/common/bin/wlst.sh (.cmd on Windows): Connect to the running server. Use the managed server port as this is a server runtime property:

wls:/offline> connect('weblogic','weblogic','t3://localhost:7002')

Go to the serverRuntime tree: wls:/mydomain/serverConfig> serverRuntime()

Navigate to the JDBCService, to your managed server name, the JDBCDataSource Runtime and finally to your datasource name:

wls:/mydomain/serverRuntime> cd('JDBCServiceRuntime/managedsrv1/JDBCDataSourceRuntimeMBeans/MyDS')

Then just suspend and resume it:

wls:/mydomain/serverRuntime/JDBCServiceRuntime/managedsrv1/JDBCDataSourceRuntimeMBeans/MyDS> cmo.suspend()
wls:/mydomain/serverRuntime/JDBCServiceRuntime/managedsrv1/JDBCDataSourceRuntimeMBeans/MyDS> cmo.resume()

use command ls() to see the the other variables and operations.

Eric Darchis
A: 

You can record your script... might be easier than writing the batch file in some cases.

You can get help with the methods via javadocs.

jonhwilliams