Exercise for Koneksys application
For this exercise i used PostgreSQL database and an embedded web server (Wildfly), for the view layer, i used Vaadin Framework.
Follow these step to create the database and tables requireds.
-
Create the database
DROP DATABASE IF EXISTS db_name; CREATE DATABASE db_name;
-
Create the table Person
CREATE TABLE person ( id_person serial not null primary key unique, name character varying not null, age integer, country character varying );
-
Create the table Telephone
CREATE TABLE telephone ( id_telephone serial not null primary key unique, number character varying not null unique, id_person integer not null, constraint telephone_person_fk foreign key (id_person) references person (id_person) );
-
Create the table PersonKnown
CREATE TABLE person_known ( id_person integer not null, id_known integer not null, constraint person_person_fk foreign key (id_person) references person (id_person), constraint person_known_fk foreign key (id_known) references person (id_person) );
-
You can create the database usin the script
database.sql
saved onresource\script
folder.
If you have an Wildfly web server, and you can manually create the datasource
for connect to the new database, only update the persistence.xml
file on
the <jta-data-source>
and put the Datasource you have create,
run maven package
and then deploy the war on your server with application
name.
In other case, follow the next steps to configure the datasource inside a embedded Wildfly server.
-
After clone the project, go inside the application folder.
-
Change the value of the database connection parameters inside the
application.properties
filedatasource.connection=jdbc:postgresql://localhost:5432/db_name datasource.user=[your-user-name] datasource.password=[your-password]
-
Compile the project.
mvn clean compile package install
-
Run the Wildfly embedded web server.
mvn wildfly:start
-
In the `pom.xml file, uncomment the line
233
, for enable wildfly home after start
<jbossHome>${project.build.directory}/wildfly-run/wildfly-10.1.0.Final</jbossHome>
- Install the PostgreSQL Driver inside the Wildfly instance (if don't have it) using the install script defined on pom.xml
mvn wildfly:execute-commands -P "install-driver"
In case you have any error for the driver location, yo can update the driver location inside
the install-postgres-driver.cli
changin the line where the location driver like this.
(i used the maven local repository iside the .cli
file)
``--resources=${settings.localRepository}/org/postgresql/postgresql/42.0.0/postgresql-42.0.0.jar``
- Install Datasource inside Wildfly instance.
mvn wildfly:execute-commands -P "install-datasource"
- Now you can deploy the application.
mvn wildfly:deploy
- Now, go to http://localhost:8080/application