As part and continuation of the tutorial/project I started in my last post (Car Rental Application with Wildfly Server and Java EE). One of the essential part of the tutorial/project is a datasource which is a name given to the connection set up to a database from a server.

You can watch out for the post where I will create the database in postgresSQL database Server. I have a postgres database with name rentalDB. To create a datasource, you have to pay attention to the following steps:

  • Download Postgresql driver, I downloaded Postgresql-9.4.1210.jar. If it is zipped, unzip and extract to {wildfly home}/standalone/deployments folder.
  • Fire up the server, you can start it from Netbeans if you have added Wildfly server to Netbeans. If not, open the bin folder in the wildfly home and click on standalone.bat to start the server. Directions on how to configure the Server will soon be up here.
  • Open your browser, go to localhost:8050 or localhost:9990 (it might not be the same port in your own context).

wildfly - geekshelm

  • By now, this file postgresql-9.4.1210.jar.deployed must have been generated in the deployment folder. It signifies that the postgresql driver have been successfully deployed.
  • When the mangement interface opens, navigate to Configurations tab -> Subsystems -> Datasources -> Non-XA -> click on new.
  • The Datasource subsystem allows you to create and configure datasources and manage JDBC database drivers. Non-XA datasources are used for applications which do not use transactions, or applications which use transactions with a single database and  XA datasources, which are used by applications whose transactions are distributed across multiple databases.


  • The next windows brings up list of options, Choose PostgreSql Datasource and proceed.


  • In the next window, input the name and JNDI name. For this tutorial/project, I used rentalDB as name and java:/rentalDB as JNDI name. Click on next and proceed.


  • In the next window is where you specify the postgresql driver to use. click on the specify driver tab and choose the postgresql driver that was deployed earlier. Click on next to proceed.


  • In the next window, confirm the connection url and security credentials. The connection url to our database is jdbc:postgresql://localhost:5432/rentalDB.
  • The next window shows the summary of all our inputs, confirm that all is correct and click on finish.
  • Go back to Configurations tab -> Subsystems -> Datasources -> Non-XA to confirm the addition of our new datasource.


  • Click on the new rentalDS datasource and choose view. Go to the connection tab, click on test connection to confirm that our exercise really worked.
  • datasource9
  • Finally, Open the service tab on the Netbeans IDE window. expand the wildfly server resource tab, under datasource you will see the rentalDB already added. In case it is missing, highlight the datasource and refresh.


We have finally created a datasource for our tutorial/project. We can now proceed to create the EJB Module.

To Instal and setup WildFly Application Server, refer to this POST.


Please enter your comment!
Please enter your name here