Data sources in EDAB are maintained in XML data registry files. These files are created and managed from within the Organizer. Detailed documentation about the data sources can be found in Section 3.1 - Data in Organizer.
To create a new data registry, open the Organizer and click the . This will pop up a dialog containing all the registries defined in EDAB.
buttonClick the Quickstart_sample
) and click the button. The registry will be created and the Data Source Manager window for the new registry will open.
EDAB allows you to connect to JDBC compliant data sources. Few examples are included in your installation.
In this tutorial, we will set up a JDBC connection to the Woodview HSQL database that comes with the EDAB Installation. If you are running EDAB using the configuration described in Section Q.1.1 - Setup then the HSQL JDBC driver will already be in the classpath of your Tomcat server, as HSQL is also used as the default EDAB database. If this is not the case, or if you are using a different database for EDAB, you will need to make sure that your database driver (hsqldb.jar
for HSQL) is in the <EDABInstallDir>/WEB-INF/lib
directory, or in Tomcat's classpath.
The classpath and Woodview sample database were already created during installation, so you can select the Woodview database in your registry. From the Data Source Manager window, click on the Databases node in the left panel, select Woodview and hit the button to reach the following Setup Database panel, where HSQL
is on the Driver List, jdbc:hsqldb:help/examples/DataSources/database/woodview
for the URL, and org.hsqldb.jdbcDriver
as the Driver. Click on both the Require Login and Save Password boxes. Next, enter sa
for the User Name and leave the Password blank will connect to the built-in HSQL database.
The procedure for connecting to other databases is very similar. First, select the type from the database list and then fill in the values. The JDBC Driver will be automatically provided so it is usually not necessary to modify this field. Here is an example connecting to a MySQL database.
URL: jdbc:mysql://192.168.0.55:3306/woodview Driver: com.mysql.jdbc.Driver User Name: root Password: ******
Leave the Auto Join and Table Name properties alone, and click the button to make sure you've entered the information correctly. Click to bring up the Data Source Manager window, where there will be an existing node under Databases for Woodview.
EDAB provides a number of different interfaces to query a database to retrieve the report data. You can type a SQL statement, use the Query Builder, or use data views to create a query interface that insulates the end user from the database structure. In this example, we will use the Query Builder to create a query.
To create a new query, click to expand the Woodview node in the left-hand frame of the Data Source Manager. Two sub-nodes will appear, one called Queries and one called Data Views. Select the Queries node and click . A dialog will appear prompting you to specify a name for the query and to select whether to launch the Query Builder or to enter an SQL statement.
Enter any name you would like, select Open query builder, and click on . The Query Builder will launch. You will see a separate window containing all of the tables for Woodview sitting over top of the main Query Builder window.
To add a table to the query, select a table in the Tables window and click the
button. You can also double click on the table name. Using one of the two methods, add the following tables to the query:CATEGORIES CUSTOMERS ORDER_DETAILS ORDERS PRODUCTS
The tables will appear in the top half of the Query Builder window. You will see the join lines connecting various fields in the tables.
To add a field to the query, you can either double click on the field in the table window or double click on the Table and Field fields in the lower (QBE) portion of the Query Builder window and select the table and field from the drop-down menu. Using either method, add the following fields to the query.
ORDERID from ORDERS COMPANY from CUSTOMERS REGION from CUSTOMERS CATEGORYNAME from CATEGORIES PRODUCTNAME from PRODUCTS UNITPRICE from PRODUCTS QUANTITY from ORDER DETAILS
In the eighth column, which should be blank, right click in theField field and select Build from the pop-up menu. This will open the Formula Builder interface allowing you to create a computed column.
To build a column, first click the Tables folder. It will expand into five nodes, one for each table you selected for the query. Opening a table folder will list all of the column fields in that table. Open up the PRODUCTS folder, select UNITPRICE and click . Then click the button. Next, insert STAINCOST from the ORDER_DETAILS table. Then click the button. Click the button and finally insert QUANTITY from the ORDER_DETAILS column. The finished formula should look like this:
button. Then double click on the(PRODUCTS.UNITPRICE + ORDER_DETAILS.STAINCOST) * ORDER_DETAILS.QUANTITY
Click the Alias from the pop-up menu. A window will appear asking you to enter a column alias. Enter "SALES" (without quotation marks) and click the button.
button and the built column will be added to the query. Next, we will give the column you built an alias. Right click on the column and selectClick the Datasheet View tab in the Query Builder. Your query will run and you should see the first thirty records of the query results.
button and you will see the column name change in the Query Builder. Now click on theNow that you have finished designing the query, select Queries for the query you have just designed.
from the File menu to save the changes. This will close the Query Builder window and return you to the Data Registry Manager window. There will now be a node underEDAB allows you to easily parameterize queries, allowing report and chart data to be dynamically filtered at run-time. In this tutorial we will add parameters to the query created in Section Q.3.1.2 - Create a Query.
To open the query that you created, select it, click the Condition field. Right click in the Condition field under the ORDERID column and select Build from the pop-up menu. This will bring up the Formula Builder allowing you to construct a condition for the query.
button in the Data Source Manager, and click the button. Your query will re-open in the Query Builder. The Tables window will open on top of the Query Builder. Click to close the Tables window and scroll down in the lower (QBE) portion of the Query Builder window until you see theDouble click on the Tables folder within the Formula Builder to expand it. Then expand the ORDERS node and double click on the ORDERDATE field. Next click the button and then click the button. This will bring up a dialog prompting you specify a name for the query parameter.
Enter StartDate
as the parameter name and click the button. The parameter will be added to the query. Then click the button. Click the button again. Enter EndDate
as the second parameter name. The finished condition should look like this
Orders.OrderDate BETWEEN :StartDate AND :EndDate.
Click Datasheet View tab. Because you have just added two parameters to the query, an initialization dialog will appear, asking you to specify a few properties for the query parameters.
to close the Formula Builder and return to the Query Builder window. Now click on theFrom this window, click on Map to a database column and select ORDERS.ORDERDATE from the drop-down menu. This will automatically fill the Default Value and Data Type options. Next, enter Start Date
into the Prompt Name, then click the button and map the EndDate parameter to the same column. Click on the Define Value drop-down menu to select an end date. Select a date far enough from the start date that by default you will have more than a couple records to work with (this makes report design easier). Change its Prompt Name to End Date
.
Click
to close the initialization window once you have specified all the options. A new dialog will appear prompting you to select a date range by which to filter the result set.Select the Start and End date that you would like and click
. You will now see the filtered result in the datasheet window. Now, click from the File menu to save the changes you have made to the query.A unique feature in EDAB is the ability to create data views. Data views are local schemas/views that allow an administrator to pre-configure a group of tables and fields, so that the end users only need to select fields and define simple conditions to create a query. Data views are also used with the ad hoc QuickDesigner. To create a data view, select the Data Views node under Woodview and click .
This will open a new dialog asking you to select database tables you would like to use. Select the following tables and add them to the Selected Tables panel by clicking on the button:
CUSTOMERS ORDERS ORDER_DETAILS PRODUCTS
Next, click on the Section 3.1.3.2.1.2 - Joins). Click to finalize the table selection. The next window allows you to select and group fields for the view. At the top of the window you can specify a name for the view. Name it Invoicing
.
Next, double click on the CUSTOMERS folder to reveal the fields for that table. Add the following fields by double clicking them or selecting them and clicking on the button:
COMPANY CONTACTNAME ADDRESS CITY STATE ZIP
Now add fields from the other tables as follows:
ORDERS:
ORDERDATE SHIPDATE SHIPTO SHIPADDRESS SHIPCITY SHIPSTATE SHIPZIP
ORDER_DETAILS:
ORDERID STAIN STAINCOLOR QUANTITY
PRODUCTS:
PRODUCTNAME UNITPRICE STAINPRICE
Now click the Customer Info
. Add two more headings in the same way, one called Shipping Info
and one called Order Info
. Once they are created, select the following fields (Using CTRL+Click or SHIFT+Click for multiple selection):
COMPANY CONTACTNAME ADDRESS CITY STATE ZIP
Once the fields are selected, click the Customer Info from the drop-down list. The fields will be moved under that heading. Next, select the following fields in the same way:
button and selectSHIPTO SHIPADDRESS SHIPCITY SHIPSTATE SHIPZIP SHIPDATE
Add these fields to the Shipping Info group the same way as before. Next, select the following fields:
ORDERDATE ORDERID STAIN STAINCOLOR QUANTITY PRODUCTNAME UNITPRICE STAINPRICE
Add these fields to the Order Info group. Next, select the CONTACTNAME field on the right side and click the button. In the dialog, specify the name Contact Name
. Repeat this for every field in order to give it proper names.
Next, select the Order ID field on the right side and click on the up arrow button to move the field to the top of the Order Info heading. Use the arrows to arrange the items in the Order Info heading in the following order:
Order ID Order Date Product Name Unit Price Stain Stain Color Stain Price Quantity
Now that the data view has been created, click the Data Views in the Data Source Manager.
button in the fields window to save the view. It will be saved as a new node underNow that the data view has been created, you can write queries against the view. This allows users to develop queries without knowing the underlying structure of the database. It also allows administrators to limit which database elements the user has access to. In this tutorial we will create a query for the data view you created in. Section Q.3.1.3 - Create a Data View.
In the Data Source Manager, select the Invoicing data view. Then click the button. This will open a dialog, prompting you to select fields from the view. To select fields, first double click on a heading to expand it. Add the following fields to the query by double clicking or selecting them and clicking on the button:
Order ID Order Date Product Name Unit Price Quantity
Once you have finished adding the fields, click Datasheet View tab.
. This will bring up a new window allowing you to set conditions, grouping, and ordering for the query. Like the Query Builder this window also allows you to preview the query result with theFirst specify a name for the query in the space provided at the top. Then double click on the Condition field for the Order Date column. This will bring up a dialog allowing you to specify a condition for the field.
Click the 2003-10-12
as the first date and 2003-12-09
as the second.
Click Datasheet View tab to preview the query. Click in the main window and the query will be saved using the name you provided. You will then be taken to a screen showing the result of the data view query. Options in this screen allow you to use the results to create a report or chart. Click in this dialog to close the interface and return to the Data Source Manager. There will now be a new node for your query under the Invoicing data view.
to close the dialog and add the condition. You will be taken back to the conditions window. Now you can click on theIn addition to database data, EDAB can also draw data from flat files(XML and text). In this tutorial we will setup a text file data source in the registry. To add a new text file, select the node labeled TXTFiles and click the button. This will bring up a dialog allowing you to specify a display name and the location for the text data source.
Enter any display name you would like (e.g. Sample
). Then click the button and browse to the help/examples/DataSources/text
directory. Select the sample.dat
file.
After you have finished entering the information, click
. You will see a new node in the Data Source Manager for the text file.