Pain-Less Database Connectivity with Jboss datasource and Oracle 10 g express

It will be pain less for you guys as i beared the pain configuring my application to connect to database with jboss datasource . so here are the steps for that :
I used JBoss version 4.0.5 and Oracle 10g express edition . both are downloadable freely from internet
Then i found the suitable driver for me as i was using java version 1.5 so i downloaded thin driver ojdbc.jar .
Then i googled and followed some suitable links :

1. Copied the thin oracle driver (ojdbc14.jar) in server\default\lib directory of

2. Copied the oracle-ds.xml file from docs\examples\jca directory of JBOSS_HOME to server\default\deploy of JBOSS_HOME.
Configured it for my use “oracleDS” is the name for my datasource , its type matching OracleXE was also defined by (explained later)
which reads as:

3.Changed to server\default\conf of JBOSS_HOME and edited standardjaws.xml for my use. added the following entry on the top under jaws element .

the type defination of OracleXE is not provided by default , i simply copied the type defination of Oracle8 and renamed it a OracleXE. (may be its not professional approach but there was no other alternative )
It works fine.

4.Edited standardjbosscmp-jdbc.xml and added
again defined the type matching here as in third step.

5.Edited login-config.xml ,added OracleDb realm as following :

<application-policy name="OracleDbRealm" >
<login-module flag="required" code="" >
<module-option name="principal" >sa</module-option>
<module-option name="userName" >sa</module-option>
<module-option name="password" />
<module-option name="managedConnectionFactoryName" >jboss.jca:service=LocalTxCM,name=oracleDS</module-option>

Thats it JBoss is ready ,

Now add the code like this in your jsp file

InitialContext ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:oracleDS");
Connection con = ds.getConnection();

and you can do it.

There is another way for connecting to data source which is :

I faced many problem in connecting and had to take help from JBoss forums Link , it realy helped.

Thats it restart JBoss server and have fun.


One thought on “Pain-Less Database Connectivity with Jboss datasource and Oracle 10 g express

  1. jasdeep, i want to connect to remote database. having ip say .
    while making connection wid oracle, i used the connection string jdbc:oracle:thin@ip:1521(port of oracle listener):SID user pwd.

    wen i used this string. it gives an error.

    please help me out
    thanx in advance..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s