我正在尝试使用部署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的属性。
答案 0 :(得分:2)
您可以在以下面板的管理控制台中完成此操作:
资源> DataSources> YOUR_DATASOURCE> WebSphere Application Server数据源属性
此处的关键是该属性名为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);