Jboss AS 5.1.0.GA change datasource to MYSQL.

Below I give the steps for changing the datasource of jboss server from hsqldb to mysql database (mainly for remembering the exact steps required, but it may also help some people).

Jboss server version = 5.1.0.GA
Mysql version = 5.1
mysql jdbc driver = mysql-connector-java-5.1.13-

bin

Below I use the directories of my setup please change those as required per your setup.
First step is to change the hsqldb ds file inside the deploy directory of jboss and replace it with the one for mysql given in the example. So :
Copy mysql-ds from C:\dev\appServers\forSeam\jboss-5.1.0.GA\docs\examples\jca and place it in the directory C:\dev\appServers\forSeam\jboss-5.1.0.GA\server\default\deploy.
Then delete hsqldb-ds from C:\dev\appServers\forSeam\jboss-5.1.0.GA\server\default\deploy.

Now lets do some change in the mysql datasource:

First open mysql-ds in your favorite editor (Notepad++ for example).

Inside you will see a line that looks like this :

<jndi-name>MySqlDS</jndi-name>

change this to:

<jndi-name>DefaultDS</jndi-name>

Change according to your needs the line that specifies the url of mysql:

<connection-url>jdbc:mysql://mysql-hostname:3306/jbossdb</connection-url>

In my case I changed it to:

<connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>

The lines below is where you specify your database credentials:

<user-name>x</user-name>
<password>y</password>

please change the above accordingly.

Now put the jar named mysql-connector-java-5.1.13-bin (which you must download from the mysql site www.mysql.com <http://www.mysql.com/>) in the directory :

C:\dev\appServers\forSeam\jboss-5.1.0.GA\server\default\lib

Now chnge the following You also need to replace the C:\dev\appServers\forSeam\jboss-5.1.0.GA\server\default/deploy/messaging/hsqldb-persistence-service.xml file with the C:\dev\appServers\forSeam\jboss-5.1.0.GA\docs\examples\jms/mysql-persistence-service.xml file.

Now if you try to run the server you will get the following erroe in the console:

jboss.deployment:id=”jboss.messaging:service=PersistenceManager”,type=Component already registered.

In order to resolve this, in your mysql-persistence-service.xml replace the following line :
|<depends optional-attribute-name=||”ChannelFactoryName”||>jboss.jgroups:service=ChannelFactory</depends>|
with the following:
|<attribute name=||”ChannelFactoryName”||>jboss.jgroups:service=ChannelFactory</attribute>|

now everything should run smoothly.

thanks

About these ads

One Response to Jboss AS 5.1.0.GA change datasource to MYSQL.

  1. I relish, result in I found exactly what I used to be looking for.

    You’ve ended my four day lengthy hunt! God Bless you man. Have a great day. Bye

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: