JBoss ships Hypersonic SQL database with its installer by default, however in production environment it is not recommend to use  Hypersonic as the database, hence it has to be switched with any of the supported databases and this article would help you to just do that in a step by step manner.

So the first question comes into our mind is that which all databases are in supported configuration ? You can get answer for this question in the below link which would show you which all databases are in the supported configuration for different versions of JBoss AS6.

http://www.jboss.com/products/platforms/application/supportedconfigurations

Steps to switch Hypersonic with an alternative database

For this example I would be using MySql database as alternative database, however the same steps can be used with different databases with there respective drivers.

  1. You have to download “mysql-connector-java-x.x.xx-bin.jar” from mysql site separately.
  2. Put “mysql-connector-java-x.x.xx-bin.jar” in the “/JBOSS_HOME/server/PROFILE/lib” directory. (here “PROFILE” means all,produciton,default etc)
  3. Create a new “mysql-ds.xml” file with the following details which is the basic configuration.
  4. <?xml version="1.0" encoding="UTF-8"?>
    <datasources>
    	<local-tx-datasource>
    		<jndi-name>DefaultDS</jndi-name>
    		<connection-url>jdbc:mysql://IP_ADDRESS:3306/YOUR_DATABASE_NAME</connection-url>
    		<driver-class>com.mysql.jdbc.Driver</driver-class>
    		<user-name>DATABASE_USERNAME</user-name>
    		<password>DATABASE_PASSWORD</password>
    		<metadata>
    		       <type-mapping>MySQL</type-mapping>
    		</metadata>
    	</local-tx-datasource>
    </datasources>
    
  5. Then put the created “mysql-ds.xml” in “/JBOSS_HOME/server/PROFILE/deploy” folder.
  6. Its done restart your server and run any client and it would connect to your database.

NOTE:

I have used the JNDI name as “DefaultDS” in the “mysql-ds.xml” because this JNDI is been used by  a variety of services in JBoss like JMS, EJB timers, UUID generator, etc. Hence if you want to use your own JNDI name then you would have to replace “DefaultDS” with the given JNDI name for the datasource in the following files the list if for JBoss AS6, you can use the below commend to get the similar list for different versions.

find . -name "*.*" | xargs grep -il "DefaultDS"

/PROFILE/conf/login-config.xml
/PROFILE/conf/standardjbosscmp-jdbc.xml
/PROFILE/deploy/uuid-key-generator.sar/META-INF/jboss-service.xml
/PROFILE/deploy/ejb2-timer-service.xml
/PROFILE/deploy/schedule-manager-service.xml
/PROFILE/deploy/hsqldb-ds.xml
/PROFILE/deploy/messaging/messaging-jboss-beans.xml
/PROFILE/deploy/messaging/*-persistence-service.xml

Regards,

Middleware Magic

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.