Book Image

Wildfly Cookbook

Book Image

Wildfly Cookbook

Overview of this book

Table of Contents (23 chapters)
WildFly Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating and removing a datasource


One of the most used features that an application comes with is the possibility to persist states (such as user information, orders, and so on) into a database. In this recipe, we will learn how to configure datasources and a JDBC 4 compliant driver.

Getting ready

Before we begin, we need to have a running database installed on our computer, or on a remote server. In this recipe, we will use a MySQL database running locally and listening on port 3306—the installation and configuration of the MySQL database server is beyond the scope of this book.

Declaring a new datasource consists of two separate steps:

  1. Installing the JDBC driver.

  2. Configuring the datasource itself.

The first step can be done in two different ways. You can install a JDBC driver by deploying it as a normal artifact, or you can install it as a WildFly module.

First, download the latest version (which, as per this writing, is "5.1.35") of the MySQL JDBC connector from http://dev.mysql.com/downloads...