Database application development is a feature of JBuilder Professional and Enterprise. Distributed application development is a feature of JBuilder Enterprise.
This chapter focuses on using JBuilder's DataExpress architecture to retrieve data from a data source, and provide data to an application. The components in the DataExpress packages encapsulate both the connection between the application and its source of the data, as well as the behavior needed to manipulate the data.
To create a database application, you retrieve information stored in the data source, and create a copy that your application can manipulate locally. The data retrieved from the provider is cached inside a DataSet
. All changes to the cached DataSet
are tracked so that resolver implementations know what needs to be inserted, updated, or deleted back to the data source. In JBuilder, a subset of data is extracted from the data source into a JBuilder StorageDataSet
subclass. The StorageDataSet
subclass you use depends on the way in which you obtain the information.
Using a provider/resolver approach, you only need two interactions between the database application and the data source: the initial connection to retrieve the data, and the final connection to resolve the changes back to the data source. The connection between the DataSet
component client and the data source can be disconnected after data is provided, and only needs to be re-established for the duration of the resolving transaction.
DataExpress components also provide support for direct data binding to dbSwing components. You simply set a property in the Inspector to bind Data to visual components.
Some of the tutorials in this chapter use a JDataStore driver to access data in a JDataStore. Others use a JDBC driver to access data in InterBase tables. Both of these options have their advantages. Which you choose depends on your application needs. With both options,
You may wish to use a JDataStore to:
You may wish to use a JDBC driver to:
JBuilder/samples/DataExpress/
. If you experience problems running the sample applications, see "JBuilder sample files" for information critical to this process.
The TextDataFile
component specifies the properties of a text file that affect its import and export, such as delimiters, field separators, and so on. This component is used when:
TableDataSet
component
StorageDataSet
to a text file
"An introductory database tutorial using a text file" steps you through creating a database application and user interface, even if you are not connected to any SQL or desktop databases. This tutorial uses data in a text file that ships with JBuilder.
For a tutorial that steps you through creating a database application using your own text file, see "Importing and exporting data from text files".
The QueryDataSet
component provides functionality to run a query statement (with or without parameters) against a table in a SQL database.
"Querying a database" steps through creating a local copy of data by executing a query and storing its results in a QueryDataSet
component.
"Using parameterized queries to obtain data from your database" outlines the steps required when adding parameters to your query statement.
ProcedureDataSet
The ProcedureDataSet
component provides functionality
to run a stored procedure against data stored in a SQL database, passing in parameters if the procedure expects them. The procedure call is expected to return a cursor or output that can be used to generate a DataSet
.
"Obtaining data using a stored procedure" steps through creating a local copy of data by executing a stored procedure and storing its result set in a ProcedureDataSet
component.
The TableDataSet
component may or may not have a formal provider or resolver of its data. Its properties allow it to import file-based data. Use this component to create a StorageDataSet
from sources other than SQL databases, for example, by importing data stored in a text file, from data computations, or to simply work with database data off-line. You can also use this component, or any other component that extends from StorageDataSet
, to directly access tables stored in a DataStore
database file.
"Importing and exporting data from a text file" describes how to import data from a text file into the TableDataSet
component. This topic discusses how to programmatically add Column
components and read in data such as date and timestamp data for which there are no standards.
DataSet
The DataSet
class is an abstract class that provides basic editing, viewing, and cursor functionality for access to two-dimensional data.
"Writing a custom data provider" discusses custom data providers, and how they can be used as providers for a TableDataSet
and any DataSet
derived from TableDataSet
.
The Column
component stores important properties such as data type and precision, as well as visual properties such as font and alignment. For QueryDataSet
and ProcedureDataSet
components, Column
components are dynamically created each time the StorageDataSet
is instantiated, mirroring the actual columns in the data source at that time.
"Working with columns" discusses column properties, persistent columns, and metadata.
For QueryDataSet
and ProcedureDataSet
components, the data source is often a SQL server database. In this case, you also need a Database
component to handle the connection to the server. See "Connecting to a database" for more information on connecting to a server. When using the TableDataSet
and TextDataFile
components, you are usually reading data from a text file. Because you are not accessing SQL server data, you do not need a Database
component.
See also:
Understanding JBuilder's DataExpress architecture
DataExpress Component Library Reference
Exploring database tables and metadata using the JDBC Explorer
Using data modules to simplify data access
![]() |
An introductory database tutorial using a text file ![]() |