gpt4 book ai didi

java - 如何从jboss数据库配置中获取密码

转载 作者:行者123 更新时间:2023-12-01 05:14:27 25 4
gpt4 key购买 nike

我的问题是我在jboss部署文件夹中配置了oracle-ds.xml。我可以获得数据源和连接的实例。现在,我想通过jboss api从数据库配置中获取密码。我现在能做什么?

数据库配置:

<datasources>
<xa-datasource>
<jndi-name>XPCDataSource</jndi-name>
<track-connection-by-tx/>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@172.17.16.49:1521:ora49</xa-datasource-property>
<xa-datasource-property name="User">workbench_0628</xa-datasource-property>
<xa-datasource-property name="Password">workbench_0628</xa-datasource-property>
<min-pool-size>10</min-pool-size>
<max-pool-size>50</max-pool-size>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
<no-tx-separate-pools/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</xa-datasource>
<mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter" name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
</mbean>
</datasources>

最佳答案

你尝试过这样的事情吗?

   Connection conn = myJBossDatasource.getConnection();
WrappedConnection wrappedConn = (WrappedConnection)conn;
Connection underlyingConn = wrappedConn.getUnderlyingConnection();
OracleConnection oracleConn = (OracleConnection)underlyingConn;

我主要使用 BEA/Oracle (Weblogic),但很久以前就这样做了...如果您查看 OracleConnection 对象,它有一些常量:

   CONNECTION_PROPERTY_PASSWORD
CONNECTION_PROPERTY_USER_NAME

关于java - 如何从jboss数据库配置中获取密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11497802/

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