Wednesday, February 25, 2009

My "virtual friend" Unnikrishnan Pillai, who I've worked with when calling Oracle Support in the past recently posted an example WLST script for creating JDBC datasources, which ended with "MultiDataSources coming soon..." (See Unni's Blog Post: http://unni-at-work.blogspot.com/2009/02/creating-jdbc-data-source-using-wlst_20.html ) I tried to add a comment to his blog with my own example WLST script for creating MultiDatasources, but received an error, so I figured I would post it here, and Unni... you can feel free to take this as a starting point and clean it up, or ignore it completely. But, I thought I would share in case there is anyone out there wondering how to do this. Feel free to post comments and/or ask questions if you need help with this script. The script creates a multiu datasource, pointing to 2 instances of an Oracle 10G RAC database...

connect('weblogic','weblogic','t3://localhost:70001')
edit()
startEdit(-1,-1,'false')

cd('/')
cmo.createJDBCSystemResource('DS1')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1')
set('Name','DS1')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDataSourceParams/DS1')
set('JNDINames',jarray.array([String('DS1')], String))
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1')
set('Url','jdbc:oracle:thin:@myDBServer1:1521:myDBSchema1')
set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
set('Password','myPass')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCConnectionPoolParams/DS1')
set('TestTableName','SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1/Properties/DS1')
cmo.createProperty('user')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDriverParams/DS1/Properties/DS1/Properties/user') set('Value','myUser')
cd('/JDBCSystemResources/DS1/JDBCResource/DS1/JDBCDataSourceParams/DS1')
set('GlobalTransactionsProtocol','TwoPhaseCommit')
cd('/JDBCSystemResources/DS1')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2')
set('Name','DS2')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDataSourceParams/DS2')
set('JNDINames',jarray.array([String('DS2')], String))
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2')
set('Url','jdbc:oracle:thin:@myDBServer2:1521:myDBSchema2')
set('DriverName','oracle.jdbc.xa.client.OracleXADataSource')
set('Password','myPass')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCConnectionPoolParams/DS2')
set('TestTableName','SQL SELECT 1 FROM DUAL')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2/Properties/DS2')
cmo.createProperty('user')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDriverParams/DS2/Properties/DS2/Properties/user')
set('Value','slims_upt')
cd('/JDBCSystemResources/DS2/JDBCResource/DS2/JDBCDataSourceParams/DS2')
set('GlobalTransactionsProtocol','TwoPhaseCommit')
cd('/JDBCSystemResources/DS2')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJDBCSystemResource('MultiDS')
cd('/JDBCSystemResources/MultiDS/JDBCResource/MultiDS')
set('Name','MultiDS')
cd('/JDBCSystemResources/MultiDS/JDBCResource/MultiDS/JDBCDataSourceParams/MultiDS')
set('JNDINames',jarray.array([String('MultiDS')], String))
set('AlgorithmType','Load-Balancing')
set('DataSourceList','DS1,DS2')
cd('/JDBCSystemResources/MultiDS')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

activate()

2 comments:

UP said...

Hi Brian,

I don't see any thing wrong in the script u are using may be u should give a
this script
a try.

I guess something would be going wrong in DS level. But not sure what.

Gud Day :)

Unni

UP said...

Hey Brian,

Thx for posting the above script
It was really helpful ..

:)

Unni