Adding MySQL datasource to JBOSS AS 7


Retrieve the MySQL Connector

The connector can be downloaded from: http://dev.mysql.com/downloads/connector/j/. The current version at the time of writing is 5.1.24, further sections of this guide assume that version number.
Unzip the connector to your downloads folder and save the location of the main JAR in a variable which we can refer to later:

Add a Module to AS 7

AS 7 uses a module system to provide isolation in class loading. We need to create a new module which contains the MySQL Connector J JAR. Move to the the AS installation directory and create the folder structure for the new module:
export JBOSS_HOME=~/Development/jboss-as-web-7.0.0.Final
cd $JBOSS_HOME
mkdir -p modules/com/mysql/main

Copy the driver jar to the new directory and move to that directory:
cp MYSQL_JAR $JBOSS_HOME/modules/com/mysql/main
cd $JBOSS_HOME/modules/com/mysql/main
Define the module in XML. This is the key part of the process. 
vi module.xml

If the version of the jar has changed, remember to update it here:
<?xml version="1.0" encoding="UTF-8"?>
 
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
  <resources>
    <resource-root path="mysql-connector-java-5.1.24-bin.jar"/>
  </resources>
  <dependencies>
    <module name="javax.api"/>
  </dependencies>
</module>
The new module directory should now have the following contents:
module.xml
mysql-connector-java-5.1.24-bin.jar

Create a Driver Reference

Now the module has been created, we need to make a reference to it from the main application server configuration file:
cd $JBOSS_HOME/standalone/configuration
vi standalone.xml

 <subsystem xmlns="urn:jboss:domain:datasources:1.0">
            <datasources>

         <!-- My Local Datasource -->
<datasource
jndi-name="java:/db" pool-name="my_pool"
enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/local_db_dev</connection-url>
<driver>mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements/>
</statement>
</datasource>

                              <drivers>
   <driver name="mysql" module="com.mysql">
   <driver-class>com.mysql.jdbc.Driver</driver-class>
                                            <xa-datasource-class>
                                                    com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
                                          </xa-datasource-class>
</driver>
                            </drivers>
           </datasources>
 </subsystem>


Start the Application Server

Now try running the application server. Make sure you run initially as a user which has write access to the modules directory where you placed the MySQL connector JAR. This is because the appication server seems to generate an index of the directories inside the JAR.
Hopefully, among the application server’s console output you should see the following:
20:31:33,843 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) Bound data source [java:/db]

Comments

Anonymous said…
Hmm it appears like your site ate my first comment (it was extremely long) so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying your blog.
I as well am an aspiring blog blogger but I'm still new to everything. Do you have any tips and hints for inexperienced blog writers? I'd really appreciate it.


my webpage ... klimatyzacja warszawa serwis
Anonymous said…
Hi my friend! I want to say that this article is awesome, nice written and come with
almost all significant infos. I would like to
peer extra posts like this .

Here is my site - klimatyzacja
Anonymous said…
bbq time / beer time is cloѕе. If I сan
just read all this blogpost in thе neхt 10 minutes І'll be able to relax.

Here is my page :: Personal Loans Bad Credit
Anonymous said…
Hello! I've been reading your site for a long time now and finally got the courage to go ahead and give you a shout out from Huffman Tx! Just wanted to say keep up the great job!

Also visit my web-site klimatyzacja serwis
Anonymous said…
Hi there colleagues, its enormous paragraph on the topic of educationand
completely defined, keep it up all the time.

Here is my weblog tani montaż klimatyzacji warszawa
Anonymous said…
And lovers are unable to hold their eyes off from such stylish wears.
This is surely just one of the need to-have belongings for any Bulls supporter.
Even pretty little newborns and small children was sporting bonnets.
Snapback hats have been your variety phenomenon
ever because the 1980s.

Feel free to visit my homepage: www.icelandtoday.is
Anonymous said…
If you are interested in enhanced functionality, you
will find that this Personal Heart Monitor watch may be what you are searching for.
With the advent of the digital age, a lot of processes have been
digitized. Invicta Women's Wildflower Quartz Round Stainless Steel Watch.

my web page :: Michele Watches
Anonymous said…
Heya just stumbled upon your website via Yahoo after I entered in, "Blogger: All About Knows and Dont knows"
or perhaps something similar (can't quite remember exactly). In any case, I'm grateful I found
it simply because your content is exactly what I'm searching for (writing a college paper) and I hope you don't
mind if I collect some information from here and I will of
course credit you as the reference. Many thanks.


Take a look at my website: visit this website
Anonymous said…
Currently it appears like BlogEngine is the preferred blogging platform out there right now.

(from what I've read) Is that what you are using on your blog?

my site - klimatyzacja biura warszawa
Anonymous said…
Hey! I know this is kinda off topic however I'd figured I'd ask.
Would you be interested in trading links or maybe guest authoring a
blog post or vice-versa? My site covers a lot of the same
subjects as yours and I feel we could greatly benefit from each
other. If you're interested feel free to send me an email. I look forward to hearing from you! Great blog by the way!

my web-site ... click the next webpage
Anonymous said…
Excellent post however I was wanting to know if you could write a
litte more on this topic? I'd be very thankful if you could elaborate a little bit more. Appreciate it!

Visit my web site - more helpful hints
Anonymous said…
Hey there! I simply want to offer you a huge thumbs up for the
excellent information you have here on this post.
I will be returning to your website for more soon.


Also visit my website :: klimatyzacja
Anonymous said…
Highly descriptive blog, I enjoyed that a lot.
Will there be a part 2?

Also visit my web page - klimatyzacja
Anonymous said…
If you want to improve your knowledge simply keep visiting this web site and be updated with the most up-to-date
gossip posted here.

Feel free to surf to my homepage - klimatyzacja
Anonymous said…
Appreciating the dedication you put into
your website and detailed information you present.
It's awesome to come across a blog every once in a while that isn't the same old rehashed information.
Great read! I've saved your site and I'm including your RSS feeds to my
Google account.

Feel free to visit my site: klimatyzacja
Anonymous said…
Hi to all, because I am really keen of reading this weblog's post to be updated regularly. It carries fastidious stuff.

Here is my web page - klimatyzacja
Anonymous said…
Wow that was odd. I just wrote an very long comment
but after I clicked submit my comment didn't show up. Grrrr... well I'm not writing all that
over again. Anyway, just wanted to say fantastic blog!


My weblog :: klimatyzacja
Anonymous said…
When some one searches for his necessary thing, therefore he/she desires to
be available that in detail, so that thing is maintained over here.



My weblog - klimatyzacja
Anonymous said…
This can be a perfect gift because it allows you to give a unique and sentimental gift with who might not be able to see the
child very often, due to living a distance away, for instance.

This will even help you save a lot of your cash money or even
credit card charges. The price of an homemade pocketbook or
purse is much less expensive and kind in your budget compared
to the price tag on that snazzy clutch you only saw in the store.



Also visit my web-site ... http://werpvintage.blogspot.com/2013/01/dagens-kk-queens.html
Anonymous said…
My brother recommended I might like this website. He was entirely right.
This publish truly made my day. You can not imagine just how so much time I had spent for this info!
Thanks!

Take a look at my homepage - web page
Anonymous said…
What's Going down i'm new to this, I stumbled upon this I've discovered It absolutely helpful and it has aided me out loads. I hope to give a contribution & help other users like its helped me. Good job.

My site: Best Anti Aging Cream
Anonymous said…
It may prove effective not only in choosing
the most appropriate types of acne killer. The red light
causes the skin to become dry, and dry skin cells and other surface impurities.


Here is my web site - the acne killer
Anonymous said…
If you want to save money and create a one-of-a-kind bassinet
that matches the nursery decor, making your own is the only way to go.
What makes bassinets so popular is their portability.
Browse through their listing for the one you are looking for.


Feel free to surf to my weblog :: loft bed with slide ()
Anonymous said…
When used in Ethmoiditis, medical therapy aims to open the
clogged pores. Suddenly, there's a varied risk placebo response rate. That way you can do to prevent how to get rid of acne scars.

Popular posts from this blog

PostgreSQL bytea and oid

Microservices Architecture with Spring Boot in 15mins