Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View weblogic_datasource.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
# WebLogic Connection
adminUserName='weblogic'
adminPassword='welcome1'
adminURL='t3://localhost:7001'
 
# DataSource Details
dsName='TestDS'
dsJNDIName='jdbc/test'
dsDriverName='com.mysql.jdbc.Driver'
dsURL='jdbc:mysql://localhost:3306/mysql'
dsUserName='root'
dsPassword='mysql'
 
# DataSource Details for WebLogic
dsTestQuery='SQL SELECT 1\r\n' # example specific for MySQL
datasourceTarget='AdminServer' # can be a cluster or another managed server
 
connect(adminUserName, adminPassword, adminURL)
edit()
startEdit()
 
cd('/')
cmo.createJDBCSystemResource(dsName)
 
cd('/JDBCSystemResources/' + dsName)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + datasourceTarget + ',Type=Server')], ObjectName))
 
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName)
cmo.setName(dsName)
 
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName)
set('JNDINames',jarray.array([String(dsJNDIName)], String))
cmo.setGlobalTransactionsProtocol('OnePhaseCommit')
 
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName)
cmo.setUrl(dsURL)
cmo.setDriverName(dsDriverName)
cmo.setPassword(dsPassword)
 
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName)
cmo.createProperty('user')
 
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName + '/Properties/' + dsName + '/Properties/user')
cmo.setValue(dsUserName)
 
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName)
cmo.setTestTableName(dsTestQuery)
 
save()
activate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.