This tutorial is written for YAWL 4.x and replaces a previous tutorial for YAWL 2.3.
In addition to using net variables in YAWL we can also store and fetch data directly from a database. In this tutorial we show how to retrieve data from a simple database table using a YAWL Data Gateway. In the previous tutorial for YAWL 2.3 Microsoft database was used. Here we will demonstrate the case with PostgreSQL. We assume that you are familiar with the basics of databases and have installed PostgreSQL and pgAdmin.
We start by creating a new database with name "CustomerDB" and owner "postgres" having password "postgres". In this database we create a table "Customers" with owner "postgres". We create columns ID:integer (primary key), Name:text, Age:integer and fill it with some data:
When we click on the magnifying glass symbol in pgAdmin while table "Customers" is selected we get the SQLeditor. There we choose the tab "Graphical Query Builder", navigate to table "Customers", select "Name" and "Age", and click on the green triangle. We should get the following query:
SELECT
"Customers"."Name",
"Customers"."Age"
FROM
public."Customers";
Now we create a new Java project named "yawlDataGateway" in Eclipse or Netbeans. We download the YAWL Library Jars, unzip them and add the yawl-lib-4.2.jar and YResourceServiceClient.jar to the build path. Furthermore, you need jdom-2.0.6.jar and hibernate-core-4.3.11.Final.jar in the build path.
The code of the class MyExternalDBGatewayImpl is attached here. We deploy yawlDataGateway.jar to ../webapps/yawl/WEB-INF/lib. We restart the YAWL engine and the editor.
We build a simple YAWL workflow as attached here. If everything works correctly, it should look like this:
The Java code is a quick hack - not very robust. Who has a more elegant solution?

Getting error in Data Gateways /dbGateways
Hi Ahense,
I am getting below error (screenshot attached) while using same .yawl or .java file to retrieve data using Data Gateways.
1.Error_in_browser.JPG
When I am loading (same) dataGateway.yawl
2.Yawl_Specification.jpg
- Java class name is available under Data Gateway properties
-Suggest us location to put .class file (if any fixed location)
3.Error_in_Mapping.JPG
Error while binding
Referring same tutorial suggested by you : http://www.yaug.org/content/working-database-gateways
YAWL Version:3.0.1
Thanks in advance for your help
Riyaz
Getting error in Data Gateways /dbGateways
I have the same problem for the data binding Xquery, do you have solved them?
jar file not in the right place
I get the same "not found" error when the compiled jar file yawlDataGateway.jar (here included in dist.zip) is not in the right place. This file goes to .../webapps/yawl/WEB-INF/lib.
Furthermore, the data gateway is not used at net level as in your screenshot but on task level as below.
Hi all, Sorry for reviving…
Hi all,
Sorry for reviving this thread, but I have tried the ahense's solution and it didn't work. The compiled file is in the right directory, and I haven't used the data gateway at net level. But I am getting the same error that riyaz.lakhani. I don't know what I am doing wrong.
Any help would be great.
Hi, you are welcome to…
Hi,
you are welcome to revive this thread. Could you tell me the versions of
you are runing?
We had tried to use data gateways in a productive setting and found that in our case using codelets was the better option. If you want to try codelets for storing data in a DMBS you can have a look at the following Youtube tutorials:
There is also a link to the supplementary material on github in the videos. Let me know if this works for you.
Hi ahense, Hey, thank you…
Hi ahense,
Hey, thank you for being so fast. Wow!
The information you have requested is:
YAWL editor is 5.0.801
YAWL engine is 5.0.408
JAVA is 11.0.17
The OS is CentOS 7 (Kernel 3.10.0-1160.83.1.el7.x86_64)
Best,
AC