如何从部署API为Websphere应用程序服务器启用preTestConnection复选框?

时间:2015-12-16 11:30:36

标签: websphere-8 websphere-portal

我正在尝试使用部署API为数据源启用validate pooled connection复选框。

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);`

当我执行此操作时,pretestconnection将添加到自定义属性,而不是 WebSphere Application Server数据源属性数据源。

请提供preTestConnections的属性。

1 个答案:

答案 0 :(得分:2)

您可以在以下面板的管理控制台中完成此操作:

资源> DataSources> YOUR_DATASOURCE> WebSphere Application Server数据源属性

然后,根据需要配置这组属性:
Screenshot of the Admin Console properties to set

此处的关键是该属性名为testConnection而不是preTestConnections

您也可以使用wsadmin脚本执行此操作:

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

您还可以使用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);