7.3.2. Installing the JDBC Driver and Deploying the DataSource
The Oracle JDBC drivers can be found in the directory $ORACLE_HOME/jdbc/lib
. Older versions, which may be more familiar to some users, had rather uninformative names like classes12.zip
but at the time of writing the latest driver version can be found in the file ojdbc14.jar
. There is also a debug version of the classes with _g
appended to the name which may be useful if you run into problems. Again, you should copy one of these to the lib
directory of the JBoss default
configuration. The basic driver class you would use for the non-XA setup is called oracle.jdbc.driver.OracleDriver
. The XADataSource
class, which we’ll use here, is called oracle.jdbc.xa.client.OracleXADataSource
.
For the configuration file, make a copy of the oracle-xa-ds.xml
example file and edit it to set the correct URL, username and password.
<datasources>
<xa-datasource>
<jndi-name>XAOracleDS</jndi-name>
<track-connection-by-tx>true</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:@monkeymachine:1521:jboss
</xa-datasource-property>
<xa-datasource-property name="User">jboss</xa-datasource-property>
<xa-datasource-property name="Password">password</xa-datasource-property>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name>
<no-tx-separate-pools/>
</xa-datasource>
<mbean code="org.jboss.resource.adapter.jdbc.vender.oracle.OracleXAExceptionFormatter"
name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">
jboss:service=TransactionManager
</depends>
</mbean>
</datasources>
We’ve used the Oracle thin (pure java) driver here and assumed the database is running on the host monkeymachine
and that the database name (or SID in Oracle terminology) is jboss
. We’ve also assumed that you’ve created a user jboss
with all the sufficient privileges. You can just use dba
privileges for this example.
SQL> connect / as sysdba
Connected.
SQL> create user jboss identified by password;
User created.
SQL> grant dba to jboss;
Grant succeeded.
Now copy the file to the deploy
directory. You should get the following output.
11:33:45,174 INFO [WrapperDataSourceService] Bound connection factory for resource adapter
for ConnectionManager 'jboss.jca:name=XAOracleDS,service=DataSourceBinding to JNDI name
'java:XAOracleDS'
If you use the JNDIView
service from the JMX console as before, you should see the name java:/XAOracleDS
listed.