k_satish22
asked on
Jython Script for JDBC
Hello HonorGod,
As per our discussion in other Question I have opend a new question.
I need a Jython script to create to create different JDBCProvides and DataSources. I have seen that you have worked on similar kind of script in below the link. I need only JDBCProvides and DataSources part of that script. JDBC Provider should be created at specifed scope.
https://www.experts-exchange.com/questions/26219904/Need-help-in-jython-script-creation-of-cluster-datasource-creation-virtualhost.html
Properties file is provided below.
I really appreciate all you help.
As per our discussion in other Question I have opend a new question.
I need a Jython script to create to create different JDBCProvides and DataSources. I have seen that you have worked on similar kind of script in below the link. I need only JDBCProvides and DataSources part of that script. JDBC Provider should be created at specifed scope.
https://www.experts-exchange.com/questions/26219904/Need-help-in-jython-script-creation-of-cluster-datasource-creation-virtualhost.html
Properties file is provided below.
I really appreciate all you help.
#-------------------------------------------------
# For Environment verification
#-------------------------------------------------
cellName =
NodeName =
Cluster =
#-------------------------------------------------
# For JAASAuthData:
#-------------------------------------------------
aliasName = newAlias
username = myUserName
password = password
#-------------------------------------------------
# For DataBase types
#-------------------------------------------------
db2 = true
SQLserver = false
oracle = false
#-------------------------------------------------
# For DB2 JDBCProvider:
#-------------------------------------------------
Scope =
db2.classpath =
db2.implClassName =
db2.JDBCname = my DB2 JDBC Provider
db2.nodeName = myNode01
db2.serverName = server1
#-------------------------------------------------
# For DB2 DataSource
#-------------------------------------------------
db2.DataSourceName = myDSN
db2.JNDIname =
#-------------------------------------------------
# For SQL Server JDBCProvider:
#-------------------------------------------------
Scope =
SQLserver.classpath =
SQLserver.implClassName =
SQLserver.JDBCname = my SQL Server JDBC Provider
SQLserver.nodeName = myNode01
SQLserver.serverName = server1
#-------------------------------------------------
# For SQL Server DataSource
#-------------------------------------------------
SQLserver.DataSourceName = myDSN
SQLserver.JNDIname =
#-------------------------------------------------
# For Oracle JDBCProvider:
#-------------------------------------------------
Scope =
oracle.classpath =
oracle.implClassName =
oracle.JDBCname = my SQL Server JDBC Provider
oracle.nodeName = myNode01
oracle.serverName = server1
#-------------------------------------------------
# For Oracle Server DataSource
#-------------------------------------------------
oracle.DataSourceName = myDSN
oracle.JNDIname =
ASKER
Hello HonorGod,
Once again thank you very much for all you help. Do you have any update on this script please.
Once again thank you very much for all you help. Do you have any update on this script please.
I have the first part (about 25-33%) done, and am continuing to work on the remainder.
ASKER
Thank you.
ASKER
Hello HonorGod,
The script is working as expected for DB2.
DB2 JDBC Provider and Datasource created as per infromation Properties file.
WASX7209I: Connected to process "dmgr" on node dmgr1ProcNode01 using SOAP connector; The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[createJDBC.prop.txt]"
JDBC Provider created successfully
Datasource created successfully
Saving configuration changes.
Thank you.
The script is working as expected for DB2.
DB2 JDBC Provider and Datasource created as per infromation Properties file.
WASX7209I: Connected to process "dmgr" on node dmgr1ProcNode01 using SOAP connector; The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[createJDBC.prop.txt]"
JDBC Provider created successfully
Datasource created successfully
Saving configuration changes.
Thank you.
Is that what you wanted?
This script, as compared to the one referenced in the original question (i.e., https://www.experts-exchange.com/questions/26219904/Need-help-in-jython-script-creation-of-cluster-datasource-creation-virtualhost.html), uses the AdminTask scripting object, instead of the AdminConfig object. This changes the way the configuration objects are defined.
This script, as compared to the one referenced in the original question (i.e., https://www.experts-exchange.com/questions/26219904/Need-help-in-jython-script-creation-of-cluster-datasource-creation-virtualhost.html), uses the AdminTask scripting object, instead of the AdminConfig object. This changes the way the configuration objects are defined.
ASKER
I want even Oracle JDBCProvider and Datasource and JAASAuthData too...
#------------------------- ---------- ---------- ----
# For DataBase types
#------------------------- ---------- ---------- ----
db2 = true
SQLserver = false
oracle = false
#------------------------- ---------- ---------- ----
# For JAASAuthData:
#------------------------- ---------- ---------- ----
aliasName = newAlias
username = myUserName
password = password
For SQL Server JDBCProvider:
#------------------------- ---------- ---------- ----
Scope =
SQLserver.classpath =
SQLserver.implClassName =
SQLserver.JDBCname = my SQL Server JDBC Provider
SQLserver.nodeName = myNode01
SQLserver.serverName = server1
#------------------------- ---------- ---------- ----
# For SQL Server DataSource
#------------------------- ---------- ---------- ----
SQLserver.DataSourceName = myDSN
SQLserver.JNDIname =
#-------------------------
# For DataBase types
#-------------------------
db2 = true
SQLserver = false
oracle = false
#-------------------------
# For JAASAuthData:
#-------------------------
aliasName = newAlias
username = myUserName
password = password
For SQL Server JDBCProvider:
#-------------------------
Scope =
SQLserver.classpath =
SQLserver.implClassName =
SQLserver.JDBCname = my SQL Server JDBC Provider
SQLserver.nodeName = myNode01
SQLserver.serverName = server1
#-------------------------
# For SQL Server DataSource
#-------------------------
SQLserver.DataSourceName = myDSN
SQLserver.JNDIname =
Can't you use the original script, to do that?
The one that I provided should allow you to specify the parameters, as long as you know what to enter.
I'm going to have to configure one using the AdminConsole to see what is used in the individual steps.
The one that I provided should allow you to specify the parameters, as long as you know what to enter.
I'm going to have to configure one using the AdminConsole to see what is used in the individual steps.
Revised to add support for Oracle "URL" resource properties use entries like the following [which worked for me]
For an Oracle Database, have the properties file use something like:
...
dbType = Oracle
providerType = Oracle JDBC Driver
implementationType = XA data source
#-------------------------------------------------
# DB/2 Resource Properties
#-------------------------------------------------
dbName =
driverType =
dbServerName =
portNumber =
#-------------------------------------------------
# Oracle Resource Properties
#-------------------------------------------------
URL = jdbc:oracle:thin:@<hostname OR IP>:<port#>:XE
createJDBC.py
ASKER
Script failed with below error
WASX7209I: Connected to process "dmgr" on node dmgr1ProcNode01 using SOAP connector; The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[Oracle_prop]"
JDBC Provider created successfully
Error: createDSN() failed: com.ibm.ws.scripting.Scrip tingExcept ion: com.ibm.ws.scripting.Scrip tingExcept ion: WASX8015E: Invalid option value for step configureResourcePropertie s: [ [ URL java.lang.String jdbc:oracle:thin:@pitentra cvip01.e05 .acsenterp rise.com:1 521:ENV05_ MMIS_OLN ] )
Saving configuration changes.
WASX7209I: Connected to process "dmgr" on node dmgr1ProcNode01 using SOAP connector; The type of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[Oracle_prop]"
JDBC Provider created successfully
Error: createDSN() failed: com.ibm.ws.scripting.Scrip
Saving configuration changes.
hm. Don't you just love those "exceedingly helpful" messages?
Wow, how much more helpful could you be? "Invalid option value"...
That tells me exactly what is wrong.... NOT.
I'm going to need your help on this one.
What version is being used?
Execute the versionInfo command from the AppServer/bin directory. And let me know what is in the "Installed product" section.
Wow, how much more helpful could you be? "Invalid option value"...
That tells me exactly what is wrong.... NOT.
I'm going to need your help on this one.
What version is being used?
Execute the versionInfo command from the AppServer/bin directory. And let me know what is in the "Installed product" section.
ASKER
The URL which I have specified "jdbc:oracle:thin:@pitentr acvip01.e0 5.acsenter prise.com: 1521:ENV05 _MMIS_OLN " is correct. When I am creating the datasource from Admin console It is getting created with the same URL.
Command generated by Command Assistance in Admin console.
AdminTask.createDatasource ('"Oracle JDBC Driver (XA)(cells/APPCell01|resou rces.xml#J DBCProvide r_13058160 56861)"', '[-name Sample -jndiName jndi/sample -dataStoreHelperClassName com.ibm.websphere.rsadapte r.Oracle10 gDataStore Helper -containerManagedPersisten ce true -componentManagedAuthentic ationAlias -xaRecoveryAuthAlias -configureResourceProperti es [[URL java.lang.String jdbc:oracle:thin:@pitentra cvip01.e05 .acsenterp rise.com:1 521:ENV05_ MMIS_OLN]] ]')
But I am not sure why I am getting that error
Installed Product
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Name IBM WebSphere Application Server - ND
Version 7.0.0.13
ID ND
Build Level cf131039.07
Build Date 10/2/10
Architecture PPC32
Installed Product
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
Command generated by Command Assistance in Admin console.
AdminTask.createDatasource
But I am not sure why I am getting that error
Installed Product
--------------------------
Name IBM WebSphere Application Server - ND
Version 7.0.0.13
ID ND
Build Level cf131039.07
Build Date 10/2/10
Architecture PPC32
Installed Product
--------------------------
Excellent.
On the Admin Console, under System Administration, select Console preferences
Add checks to the boxes labelled:
- Enable command assistance notifications
- Log command assistance commands
- Click the "Apply" button
Now, when you do something on the Admin Console, you should "often" (not always) see a link on the right "View administrative scripting command for last action"
- Configure (but don't save) an Oracle DSN,
copy / paste the Jython commands used to create it.
Thanks
On the Admin Console, under System Administration, select Console preferences
Add checks to the boxes labelled:
- Enable command assistance notifications
- Log command assistance commands
- Click the "Apply" button
Now, when you do something on the Admin Console, you should "often" (not always) see a link on the right "View administrative scripting command for last action"
- Configure (but don't save) an Oracle DSN,
copy / paste the Jython commands used to create it.
Thanks
ASKER
Here is command from Command Assistance in Admin console
AdminTask.createDatasource ('"Oracle JDBC Driver (XA)(cells/APPCell01|resou rces.xml#J DBCProvide r_13058160 56861)"', '[-name Sample -jndiName jndi/sample -dataStoreHelperClassName com.ibm.websphere.rsadapte r.Oracle10 gDataStore Helper -containerManagedPersisten ce true -componentManagedAuthentic ationAlias -xaRecoveryAuthAlias -configureResourceProperti es [[URL java.lang.String jdbc:oracle:thin:@pitentra cvip01.e05 .acsenterp rise.com:1 521:ENV05_ MMIS_OLN]] ]')
AdminTask.createDatasource
ok, so you should be able to populate the properties file using this information, for example, maybe something like:
dbType = Oracle
providerType = Oracle JDBC Driver
implementationType = XA data source
#-------------------------------------------------
# DataSource
#-------------------------------------------------
dataSourceName = Sample
JNDIname = jndi/sample
helperClassName = com.ibm.websphere.rsadapter.Oracle10gDataStoreHelper
DSNdescript =
category =
CompManAuthAlias =
ContManPersist = true
xaRecoveryAuthAlias =
#-------------------------------------------------
# DB/2 Resource Properties
#-------------------------------------------------
dbName =
driverType =
dbServerName =
portNumber =
#-------------------------------------------------
# Oracle Resource Properties
#-------------------------------------------------
URL = jdbc:oracle:thin:@pitentracvip01.e05.acsenterprise.com:1521:ENV05_MMIS_OLN
ASKER
Sorry I forgot to mention earlier. I have used similar kind of properties as you suggested. But I am still getting the same error.
#-------------------------------------------------
# For Environment identification / verification
#-------------------------------------------------
cellName = ProcCell01
nodeName =
clusterName =
serverName =
appName =
scope = Cell
#scope = Cell | Node | Cluster | Server | Application
dbType = Oracle
providerType = Oracle JDBC Driver
implementationType = XA data source
#-------------------------------------------------
# DataSource
#-------------------------------------------------
dataSourceName = Sample
JNDIname = jndi/sample
helperClassName = com.ibm.websphere.rsadapter.Oracle10gDataStoreHelper
DSNdescript =
category =
CompManAuthAlias =
ContManPersist = true
xaRecoveryAuthAlias =
#-------------------------------------------------
# DB/2 Resource Properties
#-------------------------------------------------
dbName =
driverType =
dbServerName =
portNumber =
#-------------------------------------------------
# Oracle Resource Properties
#-------------------------------------------------
URL = jdbc:oracle:thin:@pitentracvip01.e05.acsenterprise.com:1521:ENV05_MMIS_OLN
In the script, there should be two lines containing:
Change the "#" on the first line to a space. Don't just delete it, replace it with a space.
This will cause the script to display exactly what is being passed to the createDataSource() method.
Thanks
Change the "#" on the first line to a space. Don't just delete it, replace it with a space.
This will cause the script to display exactly what is being passed to the createDataSource() method.
Thanks
Before:
# print 'AdminTask.createDatasource( %s )' % `attr`
result = AdminTask.createDatasource( Provider, attr )
After:
print 'AdminTask.createDatasource( %s )' % `attr`
result = AdminTask.createDatasource( Provider, attr )
ASKER
I got below error...
WASX7017E: Exception received while running file "createJDBC.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
(no code object) at line 0
File "<string>", line 183
print AdminTask.createDatasource ( %s )' % `attr`
^
SyntaxError: invalid syntax
WASX7017E: Exception received while running file "createJDBC.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
Traceback (innermost last):
(no code object) at line 0
File "<string>", line 183
print AdminTask.createDatasource
^
SyntaxError: invalid syntax
ASKER
I am sorry my bad. Please ignore my earlier comment.
Here is the the output....
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[Oracle_prop_2]"
JDBC Provider created successfully
AdminTask.createDatasource ( ['-name', 'Sample', '-jndiName', 'jndi/sample', '-dataStoreHelperClassName ', 'com.ibm.websphere.rsadapt er.Oracle1 0gDataStor eHelper', '-containerManagedPersiste nce', 'true', '-configureResourcePropert ies', '[ [ URL java.lang.String jdbc:oracle:thin:@pitentra cvip01.e05 .acsenterp rise.com:1 521:ENV05_ MMIS_OLN ] )'] )
Error: createDSN() failed: com.ibm.ws.scripting.Scrip tingExcept ion: com.ibm.ws.scripting.Scrip tingExcept ion: WASX8015E: Invalid option value for step configureResourcePropertie s: [ [ URL java.lang.String jdbc:oracle:thin:@pitentra cvip01.e05 .acsenterp rise.com:1 521:ENV05_ MMIS_OLN ] )
Saving configuration changes.
Here is the the output....
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[Oracle_prop_2]"
JDBC Provider created successfully
AdminTask.createDatasource
Error: createDSN() failed: com.ibm.ws.scripting.Scrip
Saving configuration changes.
ASKER
I found the error....
[ [ URL java.lang.String jdbc:oracle:thin:@pitentra cvip01.e05 .acsenterp rise.com:1 521:ENV05_ MMIS_OLN ] )
insted off
[ [ URL java.lang.String jdbc:oracle:thin:@pitentra cvip01.e05 .acsenterp rise.com:1 521:ENV05_ MMIS_OLN ] ]
after correcting it. the script is working fine..
URL
[ [ URL java.lang.String jdbc:oracle:thin:@pitentra
insted off
[ [ URL java.lang.String jdbc:oracle:thin:@pitentra
after correcting it. the script is working fine..
URL
So you're all set?
ASKER
Can you please add one more module for JAAS to the script.
#------------------------- ---------- ---------- ----
# For JAASAuthData:
#------------------------- ---------- ---------- ----
aliasName = newAlias
username = myUserName
password = password
#-------------------------
# For JAASAuthData:
#-------------------------
aliasName = newAlias
username = myUserName
password = password
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much for your help.
Thank you for the grade & points.
Goodluck & have a great day.
Goodluck & have a great day.
I'm working through this...