Skip to content
  • Home
  • Search
  • Tools
  • About
  • Terms of Service Agreement
  • Log In
  • Guest

WILDFLY/JBOSS: POSTGRESQL AND MYSQL DATASOURCE CONFIGURATION

Posted on April 30, 2020August 30, 2020 By Andre Dias
database, server

Table of Contents

  • ENVIRONMENT
  • DRIVER CONFIGURATION
    • DRIVER DOWNLOAD
    • INSTALLING THE DRIVER ON THE WILDFLY SERVER (JBOSS)
      • A SYSTEMATIC WAY OF DOING THIS
      • INSTALLING THE DRIVE
    • REGISTERING THE DRIVER
      • Where? Follow the picture.
      • Discover the “<driver-class>” for your driver.
        • Turn the subpath to the respective driver name
      • TESTING THE DRIVER CONFIGURATION
    • CONFIGURING THE DATABASE’S DATASOURCE
        • Where to insert it?

ENVIRONMENT

Java 13
Wildfly 18
Windows 10 / *Nix  (also applicable adapting the commands)

DRIVER CONFIGURATION


The trick is to match the requirements of the participants.

They are:
– the application server’s (the way it requires the configuration)
– the target database version (type of database and version)
– the driver compatible with the target database (type and version)

Usually the unsuccessful configuration comes from that one or more of the requirements are not correct.
So, it is necessary to follow a method, step by step, in order to be able to identify each requirement by its turn to get the configuration done faster.

DRIVER DOWNLOAD

MySQL
dev.mysql.com/downloads/connector/j/5.1.html

PostgreSQL
jdbc.postgresql.org/download.html

 

INSTALLING THE DRIVER ON THE WILDFLY SERVER (JBOSS)

A SYSTEMATIC WAY OF DOING THIS

Here comes the first guess — how to choose it?

Considering that the driver is a connector from the application to the database, it is necessary to consider first the application’s version.
Newer libraries, newer drivers.
The last point is to check if the driver although compatible with the application it is also compatible with the target database — the one to be used by the application.

The first guess is an attempt.
If it fails, it is necessary to try another version still compatible with the application and the database.
I begin by the latest driver’s version for the target application and if it fails, I get the next older driver next to the date of the application’s libraries.
Using an approach top-down you may have the chance to get the latest compatible choice compatible with the target environment.

NOTE: sometimes, when the configuration tests passes, the application may fail for some feature.
In this case, it necessary to reconfigure to another driver older, but compatible with one of the libraries that it is causing the malfunction.

Configuration is all about putting compatible codes to work together.
So, in general, always consider the date that such codes were created and their compatibilities.

INSTALLING THE DRIVE

#1
Prepare your command that it is gonna be used on server’s console to register the driver:
module add –name=com.mysql.driver –dependencies=javax.api,javax.transaction.api –resources=/PATH/TO/DRIVER.JAR
Ex.:
– MySQL:
module add –name=com.mysql.driver –dependencies=javax.api,javax.transaction.api –resources=L:\transp\1___downloads\mysql-connector-java-5.1.49\mysql-connector-java-5.1.49-bin.jar
– PostgreSQL:
module add –name=com.postgres.driver –dependencies=javax.api,javax.transaction.api –resources=L:\transp\1___downloads\postgresql-42.2.12.jar

#2
Start jboss and go to $SERVER_INSTALL_DIR\bin..

#3
Run:jboss-cli.bat
or if *nix: jboss-cli.sh

It returns the prompt:
[standalone@localhost:9990 /]

#4
Run the command prepared above. Using the PostgreSQL cmd:
module add –name=com.postgres.driver –dependencies=javax.api,javax.transaction.api –resources=L:\transp\1___downloads\postgresql-42.2.12.jar

The commandwill create the driver content under
$SERVER_INSTALL_DIR\modules\postgres\driver\main.Check the figure.

 

 

 

The PostgreSQL procedure copies the jar file and creates the module.xml file at:
$SERVER_INSTALL_DIR\\com\postgres\driver\main

<?xml version='1.0' encoding='UTF-8'?>

<module xmlns="urn:jboss:module:1.1" name="com.postgres.driver">

    <resources>
        <resource-root path="postgresql-42.2.12.jar"/>
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>

 

#5
Do the same for MySQL.

 

 

REGISTERING THE DRIVER

#1
Edit the standalone.xml file supposing this is the one used by your server.
Sometimes it is used another, for instance the full version.
Check your configuration.$SERVER_INSTALL_DIR\standalone\configuration\standalone.xml..

#2
Add the snippet below used as example, adapting to your need.
IMPORTANT: check below how to discover the “<driver-class>” for your driver.

<driver name="mysql" module="com.mysql.driver">
	 <driver-class>org.gjt.mm.mysql.Driver</driver-class>
</driver>					
<driver name="postgres" module="com.postgres.driver">
	 <driver-class>org.postgresql.Driver</driver-class>
</driver>					

 

Where?
Follow the picture.

 

IMPORTANT:
Make sure that you insert in the right place.
Use for you module name the same used in your command.
In this example was:
module add –name=com.postgres.driver …

 

 

Discover the “<driver-class>” for your driver.

For instance, suppose the following example using mysql-connector-java-5.1.49.jar.
Copy and rename it to a temporary file as a zip file:

mysql-connector-java-5.1.49.jar.zip

 

Extract its content and to find where the Driver.class is.

In this example we found it under:

postgresql-42.2.12.jar\org\postgresql\Driver.class

 

For MySQL, was done the same and found at:

mysql-connector-java-5.1.49-bin.jar\org\gjt\mm\mysql\Driver.class

 

Turn the subpath to the respective driver name


For PostgreSQL:

org\postgresql\Driver.class ==> org.postgresql.Driver

That becomes the driver-class in the driver element:
<driver-class>org.postgresql.Driver</driver-class>

 

For MySQL:
org\gjt\mm\mysql\Driver.class ==> org.gjt.mm.mysql.Driver

That becomes the driver-class in the driver element:
<driver-class>org.gjt.mm.mysql.Driver</driver-class>

 

TESTING THE DRIVER CONFIGURATION

Start Wildfly (JBoss) and check its output on console.
If it returns clean, without any error, it is time to go to the next step, otherwise revise the steps above.

Below, there is an example of the server’s output with a configuration failure:

 

13:59:07,748 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation (“add”) failed – address: ([
(“subsystem” => “datasources”),
(“data-source” => “pgTestoneDS”)
]) – failure description: {
“WFLYCTL0412: Required services that are not installed:” => [“jboss.jdbc-driver.postgresql”],
“WFLYCTL0180: Services with missing/unavailable dependencies” => [
“org.wildfly.data-source.pgTestoneDS is missing [jboss.jdbc-driver.postgresql]”,
“jboss.driver-demander.java:jboss/datasources/pgTestoneDS is missing [jboss.jdbc-driver.postgresql]”
] }
13:59:07,758 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation (“add”) failed – address: ([
(“subsystem” => “datasources”),
(“data-source” => “pgTestoneDS”)
]) – failure description: {
“WFLYCTL0412: Required services that are not installed:” => [
“jboss.jdbc-driver.postgresql”,
“jboss.jdbc-driver.postgresql”
],
“WFLYCTL0180: Services with missing/unavailable dependencies” => [
“org.wildfly.data-source.pgTestoneDS is missing [jboss.jdbc-driver.postgresql]”,
“jboss.driver-demander.java:jboss/datasources/pgTestoneDS is missing [jboss.jdbc-driver.postgresql]”,
“org.wildfly.data-source.pgTestoneDS is missing [jboss.jdbc-driver.postgresql]”
] }

 

 

CONFIGURING THE DATABASE’S DATASOURCE

Now, the last step — datasource registering.

The example below is shown as a template that you may adapt to your need.


For PostgreSQL:

 

<datasource jta="true" jndi-name="java:jboss/datasources/pgTestoneDS" pool-name="pgTestoneDS" enabled="true" use-java-context="true" use-ccm="true">
	<connection-url>jdbc:postgresql://localhost:5432/testone</connection-url>
	<driver>postgres</driver>
	<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
	<pool>
		<min-pool-size>10</min-pool-size>
		<max-pool-size>100</max-pool-size>
		<prefill>true</prefill>
	</pool>
	<security>
		<user-name>postgres</user-name>
		<password>postgres</password>
	</security>
	<statement>
		<prepared-statement-cache-size>32</prepared-statement-cache-size>
		<share-prepared-statements>true</share-prepared-statements>
	</statement>
</datasource>

For MySQL:

 

<datasource jta="true" jndi-name="java:jboss/datasources/mysqlTestoneDS" pool-name="mysqlTestoneDS" enabled="true" use-java-context="true" use-ccm="true">
	<connection-url>jdbc:mysql://localhost:3306/testone</connection-url>
	<driver>mysql</driver>
	<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
	<pool>
		<min-pool-size>10</min-pool-size>
		<max-pool-size>100</max-pool-size>
		<prefill>true</prefill>
	</pool>
	<security>
		<user-name>root</user-name>
		<password>root</password>
	</security>
	<statement>
		<prepared-statement-cache-size>32</prepared-statement-cache-size>
		<share-prepared-statements>true</share-prepared-statements>
	</statement>
</datasource>

Where to insert it?

After the last <datasource> and before the <drivers> element.
Follow the picture.


IMPORTANT:

The datasource’s driver element:
<driver>postgres<driver>

must match the drive’s name:
<driver name=”postgres” module=”com.postgres.driver”>

 

 

 

Andre Dias
Andre Dias

Brazilian system analyst graduated by UNESA (University Estácio de Sá – Rio de Janeiro). Geek by heart.

Tags: datasource configuration drivers jboss mysql postgresql wildfly 18

Post navigation

❮ Previous Post: POSTGRESQL: RESTORING DATABASES WITH DIFFERENT USER FROM THE CURRENT WINDOWS USER
Next Post: WILDFLY/JBOSS: QUICKSTARTS EXAMPLES: org.wildfly.quickstarts 20.0.0.Beta1-SNAPSHOT ISSUE ❯

Search

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
angular
bootstrap
browser
computer science
container
data persistence
database
devops
editors
hardware
health
hosting
info
internet
it
java
javascript
network
node.js
play
protocol
security
self-help
selfhelp
server
services
soft
software engeneering
sql
support
Systems
techs
Uncategorized
versioning
web
web design
windows
wordpress

Recent Posts

  • Angular From Scratch Tutorial – Step 9: Modal
  • Angular From Scratch Tutorial – Step 8: Miscellany
  • Angular From Scratch Tutorial – Index
  • angular: Reading JSON files
  • NODE.JS: SEQUELIZE: MVC Project – 4TH STEP

Categories

  • angular (19)
  • bootstrap (6)
  • browser (4)
  • computer science (4)
  • container (1)
  • data persistence (2)
  • database (11)
  • devops (1)
  • editors (1)
  • hardware (4)
  • health (2)
  • hosting (1)
  • info (1)
  • internet (2)
  • it (1)
  • java (13)
  • javascript (32)
  • network (6)
  • node.js (1)
  • play (1)
  • protocol (1)
  • security (4)
  • self-help (1)
  • selfhelp (1)
  • server (2)
  • services (1)
  • soft (1)
  • software engeneering (1)
  • sql (1)
  • support (2)
  • Systems (1)
  • techs (3)
  • Uncategorized (2)
  • versioning (6)
  • web (1)
  • web design (5)
  • windows (3)
  • wordpress (4)

Copyright © 2025 .

Theme: Oceanly by ScriptsTown

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT