gpt4 book ai didi

api - JBoss 7 管理 API - 删除数据源

转载 作者:行者123 更新时间:2023-12-04 02:18:23 36 4
gpt4 key购买 nike

我正在尝试以编程方式删除我在 JBoss 7 中创建的数据源。

创建它很容易...

        ModelNode request = new ModelNode();
request.get(ClientConstants.OP).set(ClientConstants.ADD);
request.get(ClientConstants.OP_ADDR).add("subsystem",
"datasources");
request.get(ClientConstants.OP_ADDR).add("data-source",
dataSourceName);

request.get("jndi-name").set(dataSourceName);
request.get("pool-name").set(poolName);
request.get("use-java-context").set(Boolean.TRUE);
request.get("connection-url").set(url);
request.get("driver-name").set(driver-name));
request.get("min-pool-size").set(.minPoolSize);
request.get("max-pool-size").set(maxPoolSize);
request.get("user-name").set(username);
request.get("password").set("password");

ModelControllerClient client = ModelControllerClient.Factory.create(
InetAddress.getByName(LOCALHOST), 9999);
client.execute(new OperationBuilder(request).build());
client.close();

我的 standalone.xml 创建并启用
...
<subsystem xmlns="urn:jboss:domain:datasources:1.1">
<datasources>
<datasource jndi-name="name" pool-name="poolName" enabled="true" use-java-context="true">
<connection-url>*url*</connection-url>
<driver>driver</driver>
...
</datasource>
<drivers>
<driver...>
...
</driver>
</drivers>
</datasources>
</subsystem>
...

但是......我找不到如何以编程方式删除它。有谁能够帮助我?

谢谢 :)

最佳答案

其实很简单。您需要知道对象的完整地址,然后只需调用删除操作。

ModelNode request = new ModelNode();
request.get(ClientConstants.OP).set("remove");
request.get(ClientConstants.OP_ADDR).add("subsystem",
"datasources");
request.get(ClientConstants.OP_ADDR).add("data-source",
dataSourceName);

ModelControllerClient client = ModelControllerClient.Factory.create(
InetAddress.getByName(LOCALHOST), 9999);
client.execute(new OperationBuilder(request).build());
client.close();

关于api - JBoss 7 管理 API - 删除数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13500236/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com