Project

General

Profile

Actions

Sample-DB-worker-node » History » Revision 2

« Previous | Revision 2/19 (diff) | Next »
Udo Offermann, 02.04.2013 14:56


Sample DBWorker Node

This sample illustrates the usage of the DB_Worker_Node_Add-on and thereby how easy it is to setup a all-in-one-system comprising the z2 environment and the database. The sample web-application has a very simple database schema containing one table with a primary key and a varchar column while the UI provides just the basic CRUD actions.

The sample is provided via the repository z2-samples-dbworker.

Prerequisites

All you need is a JDK 6 distribution as described in Step_2_-_Install_and_run_in_5_minutes.

Setting up the sample

This sample is run like all samples, that is, following How to run a sample.

Assuming everything (including the z2 core and dbworker sample) is under install and your workspace is in install/workspace please import the following projects into your workspace: core from z2-base.core, environemnt and com.zfabrik.samples.dbworker.webapp from z2-samples.dbworker.

Note: if the h2 driver jar is not found, please switch the core to branch master.

Running the sample

Starting Z2.

Use the Eclipse launcher or start from the command line. The first time this will take a short moment. Watch the log output and keep an eye out for the following lines:

04/02 14:43:22 [51]...ment/dbWorker@0.1 [800]: Listening for transport dt_socket at address: 5100
04/02 14:43:22 [52]...ment/dbWorker@0.2 [800]: 04/02 14:43:22 [1]...stemStateResource [800]: Attained system state: com.zfabrik.boot.main/bootrepo_up
04/02 14:43:22 [52]...ment/dbWorker@0.2 [800]: 04/02 14:43:22 [1]...stemStateResource [800]: Attained system state: com.zfabrik.boot.main/sysrepo_up
04/02 14:43:22 [52]...ment/dbWorker@0.2 [800]: 04/02 14:43:22 [1]...stemStateResource [800]: Attained system state: com.zfabrik.boot.main/process_up
04/02 14:43:22 [52]...ment/dbWorker@0.2 [800]: 04/02 14:43:22 [1]...stemStateResource [800]: Attained system state: com.zfabrik.boot.main/worker_up
04/02 14:43:22 [52]...ment/dbWorker@0.2 [800]: 04/02 14:43:22 [1]....db.h2.H2Database [800]: Starting H2 server...
04/02 14:43:22 [52]...ment/dbWorker@0.2 [800]: 04/02 14:43:22 [1]....db.h2.H2Database [800]: H2 Console Server running at http://192.168.178.28:8082 (only local connections allowed)

Run the sample app

run http://localhost:8080/dbworker_sample and play around with the UI. You can create new entries, modify and update existing entries by clicking inside the name column and delete entries. The sample application itself is not that tricky. It uses the JDBC API in order to create the schema on demand as well as to implement the CRUD operations. A single jsp file provides the UI.

How can I use by myself?

The environment module of the dbworker sample contains the important pieces. DB_Worker_Node_Add-on lists all environment components that you have to change or add in order to configure the DB worker node feature.

Updated by Udo Offermann about 11 years ago · 2 revisions