Adding persistence to our application
In order to persist data, JPA needs a relational database; we will use the PostgreSQL database, which is pretty popular among developers and can be downloaded for free from http://www.postgresql.org/download/. It is recommended to download the latest stable release of PostgreSQL 9.x and install it using the simple installation wizard. If you don't need a full-blown database, then keep in mind that later we will also show you how to use an in-memory database provided by WildFly, which can be a really useful alternative during development.
Setting up the database
We will create a database named ticketsystem
; we will then add a user named jboss
and assign him/her all privileges on the schemas.
Open a shell under the bin
folder of your PostgreSQL installation and launch the executable psql –U postgres
. Once logged in with the password from your installation, execute the following commands:
CREATE DATABASE ticketsystem; CREATE USER jboss WITH PASSWORD...