我的问题是我在jboss deploy文件夹中配置了oracle-ds.xml。我可以获得dataSource和连接的实例。现在,我想通过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>
答案 0 :(得分:0)
你尝试过这样的事吗?
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