With a stored procedure, one or more SQL statements are encapsulated in a single location on your server and can be run as a batch. ProcedureDataSet components enable you to access, or provide, data from your database with existing stored procedures, invoking them with either JDBC procedure escape sequences or server-specific syntax for procedure calls.
This tutorial shows how to provide data to an application using JBuilder's UI designer and a ProcedureDataSet component. This example also demonstrates how to attach the resulting data set to a JdbTable and a JdbNavToolBar for data viewing and editing.
Other sample applications referencing stored procedures on a variety of servers are available in the samples/DataExpress/ServerSpecificProcedures sub-directory of your JBuilder installation, and a sample of providers is available in the samples/DataExpress/CustomProviderResolver directory.
These steps run a stored procedure that creates a table and insert, update, and delete procedures on the InterBase server (make sure you have followed the setup instructions in "Setting up InterClient and InterBase for the samples"). This procedure is written in the InterBase language. These procedures will be used both in this section and in the "Tutorial: saving changes with a JdbNavToolBar" and "Tutorial: saving changes with a ProcedureResolver".
To create this application and populate a data set using the stored procedure,
Property name | Value |
Driver | interbase.interclient.Driver |
URL | jdbc:interbase://<IP address or localhost>/<path to .gdb file> (for example, jdbc:interbase://localhost//usr/interbase/examples/employee.gdb) |
Username | SYSDBA |
Password | masterkey |
The connection dialog includes a Test Connection button. Click this button to check that the connection properties have been correctly set. Results of the connection attempt are displayed beside the button. When the text indicates Success, click OK to close the dialog.
The code generated by the designer for this step can be viewed by selecting the Source tab and looking for the ConnectionDescriptor. Select the Design tab to continue.
Property name | Value |
Database | database1 |
Stored Procedure Escape or SQL Statement | SELECT * FROM GET_COUNTRIES |
Several procedures were created when CreateProcedures.java was run. The procedure GET_COUNTRIES is the one that will return a result set. The SELECT statement is how a procedure is called in the InterBase language. The other procedures will be used for resolving data in the topic " Tutorial: saving changes with a ProcedureResolver".
Click Test Procedure to ensure that the procedure is runnable. When the gray area beneath the button indicates Success, click OK to close the dialog.
The code generated by this step is can be viewed by selecting the Source tab and looking for setProcedure. Click the Design tab to continue.
This topic shows how to create a UI for your application using dbSwing components.
This will enable you to move quickly through the data set when the application is running, as well as provide a default mechanism for saving changes back to your data source.
Among other information, the status bar displays information about the current record or current operation.
Scrolling behavior is not available by default in any Swing component or dbSwing extension, so, to get scrolling behavior, we add the scrollable Swing or dbSwing components to a JScrollPane or a TableScrollPane. TableScrollPane provides special capabilities to JdbTable over JScrollPane. See the dbSwing documentation for more information.
By default, the Save Changes button on the toolbar will save changes using a default QueryResolver. To customize the resolving capability in your application in order to edit, insert, and delete data in the running application, see