Step 1: Create Datasource.py
#!/usr/bin/python
import time
import getopt
import sys
import re
# Get location of the properties file.
properties = ''
try:
opts, args = getopt.getopt(sys.argv[1:],"p:h::",["properies="])
except getopt.GetoptError:
print 'set_datasource.py -p'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'set_datasource.py -p'
sys.exit()
elif opt in ("-p", "--properties"):
properties = arg
print 'properties=', properties
# Load the properties from the properties file.
from java.io import FileInputStream
propInputStream = FileInputStream(properties)
configProps = Properties()
configProps.load(propInputStream)
# Set all variables from values in properties file.
adminUsername=configProps.get("admin.username")
adminPassword=configProps.get("admin.password")
adminURL=configProps.get("admin.url")
dsName=configProps.get("ds.name")
dsJNDIName=configProps.get("ds.jndi.name")
dsURL=configProps.get("ds.url")
dsDriver=configProps.get("ds.driver")
dsUsername=configProps.get("ds.username")
dsPassword=configProps.get("ds.password")
dsTargetType=configProps.get("ds.target.type")
dsTargetName=configProps.get("ds.target.name")
# Display the variable values.
print 'adminUsername=', adminUsername
print 'adminURL=', adminURL
print 'dsName=', dsName
print 'dsJNDIName=', dsJNDIName
print 'dsURL=', dsURL
print 'dsDriver=', dsDriver
print 'dsUsername=', dsUsername
print 'dsTargetType=', dsTargetType
print 'dsTargetName=', dsTargetName
# Connect to the AdminServer.
connect(adminUsername, adminPassword, adminURL)
edit()
startEdit()
# Create data source.
cd('/')
cmo.createJDBCSystemResource(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName)
cmo.setName(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName)
set('JNDINames',jarray.array([String(dsJNDIName)], String))
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName)
cmo.setUrl(dsURL)
cmo.setDriverName(dsDriver)
set('Password', dsPassword)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName)
cmo.setTestTableName('SQL SELECT 1 FROM DUAL\r\n\r\n')
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 + '/JDBCDataSourceParams/' + dsName)
cmo.setGlobalTransactionsProtocol('TwoPhaseCommit')
cd('/SystemResources/' + dsName)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + dsTargetName + ',Type=' + dsTargetType)], ObjectName))
save()
activate()
disconnect()
exit()
#!/usr/bin/python
import time
import getopt
import sys
import re
# Get location of the properties file.
properties = ''
try:
opts, args = getopt.getopt(sys.argv[1:],"p:h::",["properies="])
except getopt.GetoptError:
print 'set_datasource.py -p
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'set_datasource.py -p
sys.exit()
elif opt in ("-p", "--properties"):
properties = arg
print 'properties=', properties
# Load the properties from the properties file.
from java.io import FileInputStream
propInputStream = FileInputStream(properties)
configProps = Properties()
configProps.load(propInputStream)
# Set all variables from values in properties file.
adminUsername=configProps.get("admin.username")
adminPassword=configProps.get("admin.password")
adminURL=configProps.get("admin.url")
dsName=configProps.get("ds.name")
dsJNDIName=configProps.get("ds.jndi.name")
dsURL=configProps.get("ds.url")
dsDriver=configProps.get("ds.driver")
dsUsername=configProps.get("ds.username")
dsPassword=configProps.get("ds.password")
dsTargetType=configProps.get("ds.target.type")
dsTargetName=configProps.get("ds.target.name")
# Display the variable values.
print 'adminUsername=', adminUsername
print 'adminURL=', adminURL
print 'dsName=', dsName
print 'dsJNDIName=', dsJNDIName
print 'dsURL=', dsURL
print 'dsDriver=', dsDriver
print 'dsUsername=', dsUsername
print 'dsTargetType=', dsTargetType
print 'dsTargetName=', dsTargetName
# Connect to the AdminServer.
connect(adminUsername, adminPassword, adminURL)
edit()
startEdit()
# Create data source.
cd('/')
cmo.createJDBCSystemResource(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName)
cmo.setName(dsName)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDataSourceParams/' + dsName)
set('JNDINames',jarray.array([String(dsJNDIName)], String))
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCDriverParams/' + dsName)
cmo.setUrl(dsURL)
cmo.setDriverName(dsDriver)
set('Password', dsPassword)
cd('/JDBCSystemResources/' + dsName + '/JDBCResource/' + dsName + '/JDBCConnectionPoolParams/' + dsName)
cmo.setTestTableName('SQL SELECT 1 FROM DUAL\r\n\r\n')
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 + '/JDBCDataSourceParams/' + dsName)
cmo.setGlobalTransactionsProtocol('TwoPhaseCommit')
cd('/SystemResources/' + dsName)
set('Targets',jarray.array([ObjectName('com.bea:Name=' + dsTargetName + ',Type=' + dsTargetType)], ObjectName))
save()
activate()
disconnect()
exit()
Step 2: for XA Data source properties file
fileName: DS.properties
# AdminServer connection details.
admin.username=weblogic
admin.password=teste123
admin.url=t3://app1weblogic002d:7001
ds.name=DsDoJackXA
ds.jndi.name=jdbc/DoJackXA
ds.url=jdbc:oracle:thin:@db1grepora1p:1521/dbcore
ds.driver=oracle.jdbc.xa.client.OracleXADataSource
ds.username=scott
ds.password=tiger
ds.target.type=Cluster
ds.target.name=WLS_Teste_Cluster
Step3: for noXA properties file
Filename: DSnoXA.properties
# AdminServer connection details.
admin.username=weblogic
admin.password=teste123
admin.url=t3://app1weblogic002d:7001
ds.name=DsDoMaiquelNoXA
ds.jndi.name=jdbc/DoMaiquelNoXA
ds.url=jdbc:oracle:thin:@db1grepora1p:1521/dbcore
ds.driver=oracle.jdbc.OracleDriver
ds.username=scott
ds.password=tiger
ds.target.type=Cluster
ds.target.name=WLS_Teste_Cluster
Step 4:
Below steps for create XA datasource:
[oracle@kumarSunkara]$ source setDomainEnv.sh
[oracle@kumarSunkara]$ java weblogic.WLST Datasource.py -p DS.properties
and Below Steps for create NoXA datasource:
[oracle@kumarSunkara~]$ source setDomainEnv.sh
[oracle@kumarSunkara]$ java weblogic.WLST createDS.py -p DSnoXA.properties
Step 4:
Below steps for create XA datasource:
[oracle@kumarSunkara]$ source setDomainEnv.sh
[oracle@kumarSunkara]$ java weblogic.WLST Datasource.py -p DS.properties
and Below Steps for create NoXA datasource:
[oracle@kumarSunkara~]$ source setDomainEnv.sh
[oracle@kumarSunkara]$ java weblogic.WLST createDS.py -p DSnoXA.properties
Great post I must say and thanks for the information. Education is definitely a sticky subject. it is still among the leading topics of our time. I appreciate your post and looking for more.mobile phone repair in Fredericksburg
ReplyDeletemobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg
mobile phone repair in Fredericksburg