websphere-8 - 如何从 Websphere 应用程序服务器的部署 api 启用 preTestConnection 复选框?

标签 websphere-8 websphere-portal

我正在尝试使用部署 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);`

当我执行此操作时,预测试连接将添加到自定义属性,而不是数据源的WebSphere Application Server 数据源属性

请提供 preTestConnections 的属性。

最佳答案

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

资源 > 数据源 > 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);

关于websphere-8 - 如何从 Websphere 应用程序服务器的部署 api 启用 preTestConnection 复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34310900/

相关文章:

java - 在 WebSphere 8 上调用异步 servlet 导致 AsyncIllegalStateException

maven-2 - 将 websphere 门户项目转换为 maven

java - 转换为同一类时出现 ClassCastException

linux - 将 Websphere Portal 8.5 从 AIX 克隆到 Linux

authentication - Websphere 7 门户 : Servlet checking for login status to Portal?

java - 使用 URL 重定向时传递敏感数据的最佳方式是什么?

java - Solr 在 Websphere 8.5.5 上部署为 WAR 应用程序

ssl - 在应用程序级别的 WAS 中通过 HTTPS 配置 JAX-WS Web 服务

java - 使用复合EmbeddedId(包含另一个EmbeddedId的EmbeddedId)插入JPA实体的顺序

java - JAAS 无法在 Websphere Application Server 中工作