一:加入Oracle驱动
在将Oracle驱动加入到${jboss_home}\module\com\oracle\main目录下(如果目录没有自行创建)
在${jboss_home}\module\com\oracle\main目录下创建module.xml文件,文件内容为
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.oracle">
<resources>
<resource-root path="ojdbc6-11.2.0.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
三:修改配置文件
打开${jboss_home}/standalone/configuration/standalone.xml文件
找到<datasources>节点,在该节点下添加如下内容:
<datasource jta="false" jndi-name="java:jboss/datasources/opsDS" pool-name="opsDS">
<connection-url>jdbc:oracle:thin:@192.168.0.110:1521:testdb</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<driver>oracle</driver>
<new-connection-sql>SELECT 1 FROM DUAL</new-connection-sql>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<security-domain>OPS</security-domain>
<!--
如果数据库密码不需要加密用下面配置
<user-name>paff</user-name>
<password>paff</password>
-->
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<check-valid-connection-sql>SELECT 1 FROM DUAL</check-valid-connection-sql>
<validate-on-match>false</validate-on-match>
<exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
</validation>
<timeout>
<blocking-timeout-millis>10000</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>true</track-statements>
</statement>
</datasource>
<drivers>
<driver name="oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<xa-datasource-class>oracle.jdbc.xa.OracleXADataSource</xa-datasource-class>
</driver>
</drivers>
Datasource其他参数配置见:http://www.jboss.org/schema/jbossas/jboss-as-datasources_1_0.xsd
如果用到了security-domain配置,在${jboss_home}/standalone/configuration/standalone.xml文件中找到
<subsystem xmlns="urn:jboss:domain:security:1.1">节点,在 <security-domains>节点下,添加
<security-domain name="OPS">
<authentication>
<login-module code="SecureIdentity" flag="required">
<module-option name="username" value="paff"/>
<module-option name="password" value="-7009ff471602d737"/>
</login-module>
</authentication>
</security-domain>
四:密码加密生成
java -cp ${jboss_home}/modules/org/picketbox/main/picketbox-4.0.7.final.jar;${jboss_home}/modules/org/jboss/logging/main/jboss-logging-3.1.0.GA.jar org.picketbox.datasource.security.SecureIdentityLoginModule paff