2

I am trying to enable validate pooled connection checkbox for a datasource using deployment api.

AttributeList preTestConnections = new AttributeList();
preTestConnections.add(new Attribute("name", "preTestConnections"));
preTestConnections.add(new Attribute("type", "java.lang.Boolean"));
preTestConnections.add(new Attribute("value", String.valueOf(dsc.isvalidationOnMatchEnbled())));
configService.addElement(session, resourcePropertySet, "resourceProperties", preTestConnections, -1);`

When i do the able the pretestconnection is added to custom properties instead WebSphere Application Server data source properties of datasource.

Please provide the attribute for preTestConnections.

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
kusumat
  • 319
  • 3
  • 9
  • 21

1 Answers1

2

You can accomplish this in the admin console in the following panel:

Resources > DataSources > YOUR_DATASOURCE > WebSphere Application Server data source properties

Then, configure this set of properties how you desire:
Screenshot of the Admin Console properties to set

The key here is that the property is called testConnection not preTestConnections

You can also accomplish this using wsadmin scripting:

AdminConfig.modify(
  '(cells/myCell/nodes/myNode/server/server1|resources.xml#ConnectionPool_1)',
  '[[testConnectionInterval "0"] [testConnection "true"]]') 

You can also accomplish this using the ConfigService API:

AttributeList preTestConnections = new AttributeList();
preTestConnections.add(new Attribute("name", "testConnection"));
preTestConnections.add(new Attribute("type", "java.lang.Boolean"));
preTestConnections.add(new Attribute("value", String.valueOf(dsc.isvalidationOnMatchEnbled())));

configService.addElement(session, resourcePropertySet, "resourceProperties", preTestConnections, -1);
Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
  • Tried using test connection instead of preTestConnections. Still i got the properties into Data sources > TestDatasource> Custom properties. Can i have API to get list of Datasource properties. – kusumat Dec 17 '15 at 05:28
  • Have you tried doing this manually through the Admin Console yet? If you do the operation manually using the UI, you will be able to see what scripting gets generated for the corresponding interaction with the UI. – Andy Guibert Dec 17 '15 at 13:40
  • I have added that in admin console. – kusumat Dec 18 '15 at 04:52
  • resources.xml script is effecting when i change validate existing pooled connection. – kusumat Dec 18 '15 at 10:05