NOTE: The views and information expressed in this document represent those of its author(s) who is solely responsible for its content. Borland does not make or give any representation or warranty with respect such content.
Introduction:
As we are all aware, Borland's JBuilder makes
it incredibly easy to create 2-tier database applications. A couple of
areas that seem to cause a great deal of questions include the following
subjects: parameterized queries and Data Modules. In the following
simple example, we will walk through the steps needed to use a Data Module,
and how to put queries that use parameters inside a Data Module. You will
see that Borland makes it quite simple to implement this process.
In just seven (7) simple steps, we will make an application that will introduce
both Data Modules, and parameterized queries. The lab is constructed using
JBuilder Client/Server 1.01 however, you could also use JBuilder Professional
1.01.
Before we get started, lets ask the obvious questions: what are parameterized
queries and why would I use them, and second, what is a Data Module and
why would I use it? To answer the first question I refer to the JBuilder
help to give the definition:
"A parameterized SQL statement contains variables, also known as parameters,
the values of which can vary at run time. A parameterized query uses
these variables to replace literal data values, such as those used in a
WHERE clause for comparisons, that appear in an SQL statement. These
variables are called parameters. Ordinarily, parameters stand in
for data values passed to the statement. You provide the values for
the parameters before running the query. By providing different sets
of values and running the query for each set, you cause one query to return
different data sets."
Data Modules are non-visual containers that can be used to hold all of
your non-visual components, especially the database components. Data
Modules give a separation between your presentation layer and your business/data
layer in a 2-tier model.
The Lab:
The lab is quite simple by design. It
is meant to give you an introduction to the JBuilder environment and the
work-arounds for Sun's Java JDK and Borland's Data Modules. It will consist
of a limited interface that includes the following JBCL (JavaBeans Component
Library) components:
The application will be responsible for returning
whether or not a Company exists in a database. We will pass the contents
of the FieldControl to the parameter in the Data Module and the Data Module
will search the database and return the result set to the calling program.
Parameterized queries can be run with named parameters, with parameter
markers, or with a master-detail relationship. This lab only covers
named parameters, while the other topics are outside the scope of this
paper. Please refer to the JBuilder help book: "Database Application
Developer's Guide" for more information.
Connect with Us