Posted on

Wildflyadmin Errata

Page 68: The Datasource creation using the Admin Console was missing the JDBC Driver installation step. That can be done via the CLI as follows:


In book copies delivered after the 12th March 2014 the section named “Configuring a Datasource using the Admin Console” has been replaced by the following one in order to avoid using multiple management instruments at the same time:

Manual Datasource configuration

Actually this is not the quickest way to configure a Datasource but we decided to include it as first option as it is a good learning exercise that includes manual module creation and understanding of where changes are applied in the server configuration. It can be broken down in the following steps:

  • JDBC Module creation 
  • Datasource and Driver definition in the server configuration file

Let’s see each step in detail:
JDBC Module creation
As we have learnt, the application server modules are installed in the application server’s modules folder. In order to install the JDBC Driver as module you need to perform the following steps:

  1. Create a file path structure under the JBOSS_HOME/modules directory. For example, in order to install a MySQL JDBC driver, create a directory structure as follows: JBOSS_HOME/modules/com/mysql/main. 
  2. Copy the JDBC driver JAR into the main subdirectory. 
  3. In the main subdirectory, create a module.xml file containing the following definitions (just adapt the JDBC driver name to your case): 
<?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"/>     <module name="javax.transaction.api"/>   </dependencies> </module>

 Done with the JDBC module installation, check that you have the following filesystem structure under your modules tree:

Now restart the application server and move

to the next section, where we will be configuring the data source into the application server.
Configuring the Datasource and JDBC Driver
As it is, we have just a module named “com.mysql”installed on our application server which barely loads a library named mysql-connector-java-5.1.24.jar. In order to configure a Datasource we will add a definition of the Datasource and of the JDBC driver into your server configuration file.
Therefore, open the standalone.xml file (or whatever configuration you want to install it to) and include the following elements:

<datasources> . . . .    <datasource jndi-name="java:/jboss/datasources/MySQLDS" pool-name="MySQLPool" enabled="true">       <connection-url>jdbc:mysql://localhost:3306/mysqlschema</connection-url>       <driver>mysql</driver>       <security>          <user-name>jboss</user-name>          <password>jboss</password>       </security>    </datasource>    <drivers>       . . . .       <driver name="mysql" module="com.mysql"/>    </drivers> </datasources>

As you can see we have nested into the datasources element a definition for the Datasource that is bound under the JNDI name “java:/jboss/datasources/MySQLDS”. Next, we have included the connection-url which points to a MySQL server on localhost running a “mysqlschema”. Next element is the driver name which references the “mysql” driver defined into the “drivers” section. Last mandatory element that we have included is the user-name and password information that is nested within the security section.

Reload your server configuration or restart the server in order to apply the changes.

Posted on

Connect with us

{AF template=”round_bended_corner”}
Are you running a blog ? or an IT site which produces technical articles about Java technology ? then consider becoming an affiliate partner. Include an Amazon-like banner of our books and start gaining money! We offer very high royalties for sales arriving from affiliate sites. Here’s an example of royalty you can gain based on your Google Site Rank:

PR 0/1: 25% of the eBook price

PR 2:  35% of the eBook price

PR 3:  45% of the eBook price

PR 4:  55% of the eBook price

PR >4:  70% of the eBook price


Just mail us about your blog at and we will connect you as soon as possible. {/AF}

Posted on

Become an author for ITBuzzPress

{AF template=”round_bended_corner”}
If you’re a developer/architect and you’re interested in writing for ItBuzzPress — even if you’ve never written anything before — feel free to contact us. We’ll be more than happy to take you on as an author if you are expert at one technology.
We are a young publishing company made up of a bunch of programmers, a couple of editors and marketing/sales staff that work closely with authors to discuss project ideas, assess the viability of proposals, and develop manuscripts — our goal is to help our authors write the best books they can.
Besides this, you can be sure you will get here the highest royalty on the market!
If you have a book idea or proposal, please send us your resume, some samples of your previous writing, and an outline of your book idea to {/AF}