Like I wrote earlier in my previous post on the Car Rental Application, I will be using Wildfly Application Server, Java EE and a Postgres database as the datasource. Incase you missed the post on how to setup and install Wildfly Application Server, refer to this POST to get updated.
PostgreSQL, often simply Postgres, is an object-relational database (ORDBMS) – i.e. a RDBMS, with additional (optional use) “object” features – with an emphasis on extensibility and standards-compliance. As a database server, its primary function is to store data securely, and to allow for retrieval at the request of other software applications. It can handle workloads ranging from small single-machine applications to large Internet-facing applications (or for data warehousing) with many concurrent users.
Below are the necessary steps to kick it off:
- You have to first download it, head down to website or simply use this link to accomplish that mission. Make sure you choose the installer that is specify to your platform, mine is Windows OS.
- Install it as usual. During the installation you will be prompted to setup login/security/user credentials.
- After the installation, you can either choose to use web browser to access Admin Interface pgAdmin or use pgAdmin GUI tools which can be found in C:/program files/postgreSQL/pgAdmin3/bin folder. Double click on pgAdmin3 to open.
- When the GUI loads, you will see a hierarchy tree with Server group node on top, expanding the node, you will see Servers under it. Expanding the Server node, you will see the local PostgreSQL Database server (localhost:5432) with any other Postgres server installed. Expanding the PostgreSQL server, you will see the Database node which houses all the created databases and their respective schemas.
- Right-click on the Database node, choose new Database. In the context of this tutorial/project, I created a database with name rentalDB. The newly created rentalDB database will appear under the Database node.
- Right-click on rentalDB, choose add new table. A window will appear where you will enter the table name if necessary the table columns but just create new id column and click on OK.
- Postgres as I found out doesn’t support automatic auto increment like MySQL. You have to create a Sequence to take care of that. To create a new Sequence, either right-click on rentalDB and choose new sequence or expand rentalDB node, right-click on sequence and choose add new Sequence. Just specify the sequence name (info-sequence), owner and click the ok button.
- Run the Sql in the image to add the Sequence to the rentalDB info table.
- I love accessing, adding columns and handling my databases from Netbeans IDE. To add/access the rentalDB database from Netbeans, open your Netbeans IDE. Open the service tab, right-click on Databse node then choose new Database.
- Specify the host, database name, port, username, password and JDBC url. You can click the test connection button to verify that you are on the right path.
- You can now add the rest of the columns.
After this exercise, you can now proceed to create a datasource in the Wildfly Application Server using the rentalDB as database as specified here.
Since our tools are almost complete, we can now proceed to the business part of the show (Java EE).