Project

General

Profile

Database Choice

By default, the Hotel sample project is configured to use the H2 database. H2 was chosen for the demo because it is implemented in Java and when used in embedded mode (as it is in this case), it requires virtually no deployment effort. Since there is no installation or configuration of an external database, this is the simplest way to go if you are trying to get the demo up and running quickly.

The project build also provides the option to use a PostgreSQL database as the back end. If this is your first look at FWD and you just want to get the sample application going, we recommend staying with the default of using H2 as the back end. However, if you already have gotten the sample application running and now you want to confirm that a PostgreSQL back end can be used, here is what you need to do:

  1. Install and configure the PostgreSQL database server, create a database cluster, and install the base support for PL/Java. This process is documented in Database Server Setup for PostgreSQL on Linux (note: these instructions are for Linux only at this time). Go only as far as restarting the database cluster. The sample application project build will do the rest.
  2. Enable PostgreSQL as a backing database in the project build. There are two ways to do this, which are described in the next sub-sections.
Automate the PostgreSQL configuration

The automated way is to modify the hotel.input.linux (or hotel.input.windows) file by changing the h2 line and adding two other lines after it (with the target PostgreSQL host and port):

Linux Windows
...
hotel
postgresql
localhost
5433
fwd_admin
admin
...
...
hotel
postgresql
localhost
5433
fwd_admin
admin
...

After this, running prepare_hotel.sh (or prepare_hotel.cmd for Windows) will automatically configure the backend database to target your specified PostgreSQL installation, for both import and runtime.

Manual configuration for PostgreSQL
To automated steps done by the previous sub-section can be done manually by following these steps, assuming you have already prepare the Hotel project with H2 database:
  • modify the build.properties file and change the db.h2=true line to db.h2=false, and db.postgresql=false to db.postgresql=true (this will override the default setting for the same property in build.xml). This will allow the import to target the PostgreSQL database.
  • modify the deploy/server/directory.xml file to access the PostgreSQL database:
    • identify the server/standard/database/hotel node and delete it
    • open the deploy/server/directory_db_postgresql.xml.template and make the following replacements. Once these replacements are executed (for all occurrences), copy the <node class="container" name="hotel"> node as a child for the server/standard/database/ node in deploy/server/directory.xml.
String Replacement
[dbname] hotel
[dbhost] localhost or your target PostgreSQL host name or IP
[dbport] 5433 or your target PostgreSQL database port
[dbuser] fwd_user or your DB role name
[dbuserpass] user or your DB role password

If the PostgreSQL server was installed successfully and a FWD database cluster was created and configured properly, a PostgreSQL database for the sample application will be created and populated with data when you next deploy the project (see below).