Wednesday, October 19, 2016

Creating a MySQL Datasource in WildFly 10


In this message, I will demonstrate how to create a data source to connect WildFly to a MySQL database. The process with other databases, in particular with PostgreSQL should be pretty much identical. This configuration involves two steps: first uploading the driver, second create the datasource itself, using this driver. Let us start by uploading the driver. As usual, go to the address http://localhost:9990 (assuming that this is the management port of your server) and select the "Deployments" tab:



 Next, pick the driver file (a jar like the following):

And that is it for the first step.

Now, for the creation of the data source, go to the Configuration tab and select:

Subsystems-->Datasources--> Non XA (for locally managed transactions). Pick the "Add" button and select the database you want:


Now, let's fill the gaps:


The name we use in step 2 must exist in the "Detected Driver" list:


This is exactly the same name we had in the previous view:

Let's move on. Now be careful to introduce the right database in the URL (you might need to create it in MySQL). In this case, project2db:


 And we have a summary view, before finishing the request:



 The final view should be something like this:

Good luck!