JAVA EXAMPLE PROGRAMS

JAVA EXAMPLE PROGRAMS

Publish Your Article Here

How to configure Data Source (JDBC Connection Pool) in JBoss AS 7 standalone mode?


This page tells you how to configure Data Source (JDBC Connection Pool) on JBoss AS 7.x server on standalone mode. Here are the step by step instructions. We are configuring Oracle database.

1) Download ojdbc6.jar file from Oracle Database 11g Release 2 JDBC Drivers

2) Goto JBoss_home_directory/modules folder.

3) Create folder structure like 'com/oracle/ojdbc6/main/' inside JBoss_home_directory/modules folder.

4) Create module.xml file inside main folder, and paste below content inside module.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.oracle.ojdbc6">
    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
	<module name="javax.transaction.api"/>
    </dependencies>
</module>

5) Copy ojdbc6.jar file inside main folder along with module.xml file.

6) Goto JBoss_home_directory/standalone/configuration folder, and open standalone.xml file.

7) Search for datasources and have below configuration:

<datasources>
    <datasource jndi-name="java:jboss/jdbc/JNDIName" 
    				pool-name="OraclePool" enabled="true" use-java-context="true">
        <connection-url>jdbc:oracle:thin:@localhost:1521:sid</connection-url>
        <driver>oracle</driver>
        <security>
            <user-name>user name</user-name>
            <password>password</password>
        </security>
    </datasource>
    <drivers>
        <driver name="oracle" module="com.oracle.ojdbc6">
            <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
            <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
        </driver>
    </drivers>
</datasources>

Done... your datasource configuration is ready. Use above configured data source to connect to database.

<< Previous Program | Next Program >>

JBoss configuration examples

  1. How to start/stop JBoss AS 7 in standalone mode?
  2. How to load external property file in JBoss 7 classpath?
  3. How to configure Data Source (JDBC Connection Pool) in JBoss AS 7 standalone mode?
  4. How to configure database failover and high availability in JBoss 7 Datasource?
Java2Novice - YouTube Channel
  1. Python Tutorial for Beginners
Knowledge Centre
What is fail-fast in java?
A fail-fast system is nothing but immediately report any failure that is likely to lead to failure. When a problem occurs, a fail-fast system fails immediately. In Java, we can find this behavior with iterators. Incase, you have called iterator on a collection object, and another thread tries to modify the collection object, then concurrent modification exception will be thrown. This is called fail-fast.
Famous Quotations
The very best thing you can do for the whole world is to make the most of yourself.
-- Wallace Wattles

About Author

I'm Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment.

If you come across any mistakes or bugs, please email me to [email protected].

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java™ Platform Standard Ed. 8 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2019 by Nataraja Gootooru. All Rights Reserved.