Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need jacl script help for websphere to create custom property for datasource

 
kalam king
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to run a script a created, the script does not give any errors but does not give any results as well.

I am trying to add a custom property for data sources

Below is the script. Please let me know if you need more information. Kindly review and let me know if i am missing something or i have done it wrong.


proc ds_custom_prop {} {

global AdminConfig
set cellid [$AdminConfig getid /Cell:/]
set cellName [$AdminConfig showAttribute $cellid name]
set nodeId [$AdminConfig getid /Cell:$cellName/Node:/]
set nodeName [$AdminConfig showAttribute $nodeId name]
set jdbcproviderid [$AdminConfig getid /Cell:$cellName/Node:$nodeName/JDBCProvider]
set jdbcprovidername [$AdminConfig showAttribute $jdbcproviderid name]
set datasourceid [$AdminConfig getid /Cell:$cellName/Node:$nodeName/JDBCProvider:$jdbcprovidername/DataSource]
set datasourcename [$AdminConfig showAttribute $datasourceid name]
set newds [$AdminConfig getid /Cell:$cellName/Node:$nodeName/JDBCProvider:$jdbcprovidername/DataSource:$datasourcename]
$AdminConfig required J2EEResourceProperty
set propSet [$AdminConfig showAttribute $newds propertySet]
set name [list name useRRASetEquals]
set value [list value true]
set rpAttrs [list $name $value]
$AdminConfig create J2EEResourceProperty $propSet $rpAttrs
$AdminConfig save
}
 
Deepak Pant
Ranch Hand
Posts: 446
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you not using Jython? JACL support in WAS has been deprecated.

I have extensive coding in Jython so I can help you out with most the Jython script related to creation of custom property for datasource.

Let me know
 
aloysius pious
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how delete it if exist already...

I want to check if exist already...if exist delete and create it...if its does not the create it as new...
 
aloysius pious
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there is two jython script....first one is for property file end with prop.py, this will supply the value to actual jyhon named "cutom_prop.py"....or you can do hard code these custom property value....
If you use property file then you can create N number of custom propery in few second....
main script will search for specific Datasource name and set the custom property value for that...

if you need multiple custom propery for different datasources then keep property file like(ds_name0,ds_name1,ds_name2)...same way for (custom_desc0,custom_desc1,custom_desc2)...so that just we can use for loop to set all the custom properties...

Variable ==>range(2)----on-----for a in range(2):----depends on how many you want to set....
===========================================================================
prop.py
==========
##############################DataSource Creation-Begin#############################
ds_name0="Client DataSource"

#---------------------------------------------------------------------------
custom_desc0="Determines whether the data source establishes read-only connections,By default this value is false."
custom_property0="readOnly"
custom_value0="true"
custom_type0="java.lang.Boolean"
custom_required0="false"

#**************************************************************************************
ds_name1="HOST JDBC DataSource"
#---------------------------------------------------------------------------
custom_desc1="Determines whether the data source establishes read-only connections,By default this value is false."
custom_property1="readOnly"
custom_value1="true"
custom_type1="java.lang.Boolean"
custom_required1="false"
##############################################################################
cutom_prop.py
===========
import sys
import re
import string
import time
import prop
##########################Custom properties for Datasources-Begin#######################
log_it ('Creating Custom properties for Datasources ...')
for a in range(2):
dataSource = AdminConfig.getid('/DataSource:"'+eval("prop.ds_name"+str(a))+'"/')
resourcePropertySet = AdminConfig.showAttribute(dataSource,'propertySet')
property = ['name',''+eval("prop.custom_property"+str(a))+'']
value = ['value',''+eval("prop.custom_value"+str(a))+'']
type = ['type',''+eval("prop.custom_type"+str(a))+'']
required = ['required',''+eval("prop.custom_required"+str(a))+'']
resourceProperty = [property,value,type,required]
AdminConfig.create('J2EEResourceProperty',resourcePropertySet,resourceProperty)
a=a+1
#endFor
log_it ('Saving Configuration ...')
AdminConfig.save( )
log_it ('OK')
#endDef
###########################Custom properties for Datasources-End#######################
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic