I tested the following instructions on a MACOSX Lion. The aim is to connect to Oracle 11g server from
a JBoss 7 application server.
Use ojdbc6.jar downloaded from Oracle web site.
1) mkdir -p <jboss_home>/modules/com/oracle/db/main
2) cp xxx/ojdbc6.jar <jboss_home>/modules/com/oracle/db/main
3) create a module.xml file in <jboss_home>/modules/com/oracle/db/main
< module xmlns = "urn:jboss:module:1.0" name = "com.oracle.db" >
|
4) modify the configuration file in <jboss_home>/standalone/configuration/standalone.xml
In the datasources section, add
<datasource jndi-name="java:/jdbc/Int8rDS" pool-name="OracleDS"
enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>
jdbc:oracle:thin:@(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)(HOST = xxx.vvv.cc)(PORT = 10121))
(ADDRESS =
(PROTOCOL = TCP)(HOST = xxx.vvv.cc)(PORT =
10121))
(ENABLE=BROKEN)
(LOAD_BALANCE = on)
(CONNECT_DATA =
(SERVER =
DEDICATED)
(SERVICE_NAME = xxx.vvv.cc)
(FAILOVER_MODE = (TYPE =
SELECT)(METHOD = BASIC)(RETRIES = 200)(DELAY = 15))
)
)
</connection-url>
<driver>
ojdbc6.jar
</driver>
<security>
<user-name>xxx</user-name>
<password>xxx</password>
</security>
</datasource>
And in the drivers section
<driver name="ojdbc6.jar" module="com.oracle.db">
<xa-datasource-class>
oracle.jdbc.xa.client.OracleXADataSource
</xa-datasource-class>
</driver>
5) restart the server and test with the command line
<jboss_home>/bin/jboss-cli.sh --controller=localhost:9999
connect
/subsystem =datasources:installed-drivers-list
|
6) Change the <security> tag in datasource definition in order to use Encrypted passwords (http://middlewaremagic.com/jboss/?p=1026)
The first step is to modify the previous definition inside the standalone.xml config file:
<security>
<security-domain>
encrypted-ds
</security-domain>
</security>
The second step is to create the security domain as mentioned inside the standalone.xml configuration file. For this we need also to encrypt the password, using the following procedure (from your command line terminal):
export JBOSS_HOME=path_to_jboss
export CLASSPATH=$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:$CLASSPATH
java org.picketbox.datasource.security.SecureIdentityLoginModule PasswordXYZ
Encoded password: -5bbc51443039e029747687c1d9ec6a8d
{code:xml}
<security-domain name="encrypted-ds" cache-type="default">
<authentication>
<login-module code="org.picketbox.datasource.security.SecureIdentityLoginModule" flag="required">
<module-option name="username" value="dbUserOne"/>
<module-option name="password" value="-5bbc51443039e029747687c1d9ec6a8d"/>
<module-option name="managedConnectionFactoryName" value="jboss.jca:service=LocalTxCM,name=OracleDS"/>
</login-module>
</authentication>
</security-domain>
{code}
Comments