Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column
Info

The database connector maps between HTTP requests issued from  forms to SQL queries executed against your database. The connector enables you to use the database of your choice to save and load your form data. You can create a new database or you can automatically generate forms that connect to your existing database tables.

To successfully complete this tutorial, you will need:

You can download the completed application and then upload it to your account. This will provide a reference for the example forms described below.

Info

There are additional resources designed to help you learn how to use the power of forms with your database. Refer to Database Connector Examples for more information.

Column
width240px

On this page:

Table of Contents
maxLevel1


Introduction

The database connector maps between HTTP requests issued from  forms to SQL queries executed against your database. The connector enables you to use the database of your choice to save and load your form data. You can create a new database or you can automatically generate forms that connect to your existing database tables to save and load data.

...

Later, we will also write data back to the database creating new records and updating existing ones. This tutorial does not cover advanced areas such as autocreate, autodelete, date/timestamp considerations. See the documentation for more detailed coverage of these topics.

...

If you have not installed the database connector please visit Connecting to your Database Connector for instructions.

To use the database connector, you must first configure it so that it can find your database and connect to it. Here are examples for MySQL and MS Access.

...

  • The 'localhost:8082' is obvious and points to the database connector inside a the tomcat servlet container (e.g. Tomcat) on localhost and listening on port 8082.
  • 'database' refers to the context path for the database connector web application running inside Tomcat.
  • 'BIRT' refers to the name of the queryset defined above.
  • 'allCustomers' is the name of the query.
  • Since we are issuing an HTTP GET from the browser, this maps to the <retrieve> SQL.
  •  _mediaType=xml tells the connector to return an XML document. This is the default; if you leave out a _mediaType, the connector will return XML.
    When the HTTP GET is issued, the connector executes the <retrieve> SQL for the 'allCustomers' query in the 'BIRT' queryset using the resource definition to connect to the appropriate database. The data in the resultset is converted to XML and returned.

...

  1. Make a copy of the form from Example 4 above and open it for editing.
  2. We can hide the Order Info section since it does not contain information entered by the user. Select the section by clicking on its header and uncheck the Visible checkbox in the properties pane. The entire section should gray out.
  3. In the properties panel on the left, open the Data Sources pane by clicking on it.
  4. Click 'New from XSD'.
  5. You should see your schema in the resulting dialog box. Expand it and add the 'createOrderDetail' element to the form by clicking the + icon next to it.
  6. Close the dialog box by clicking X in the top right corner.
  7. In the Data Sources pane, expand the createOrderDetail data source by clicking on the + icon to the left.
  8. Click the + icon next to the row element.  will generate controls in the form. Note that  automatically generates a repeating element since a single Order can contain any number of line items.
  9. You can drag and drop to re-arrange as you wish.
  10. Rename the Section named Row to Order Line.
  11. Name the repeat control OrderLines. Take note of the "s" in the name.
  12. Select the Product Code input control and in . In the properties pane set panel:
    1. Set the name to pc
    2. Select Dropdown from the Display As property list.
  13. Select the Onum control inside the Order Line section and in the properties pane set the name to olonum. Uncheck the Visible property.
  14. Select the Order Line Number control inside the Order Line section and in the properties pane set the name to oln. Uncheck the Visible property.
  15. Set default values in the Onum and Cnum controls inside the Order Info section and in the Onum and Order Line Number controls inside the Order Line section. You can set any values since we will be overriding them in a rule. We need to set a default value otherwise  will gray out the Submit button and the form cannot be submitted.

...