JDBC TUTORIAL

Testing and Debugging Tutorial

Updated: 01 Mar 2024

Introduction

As a major designer of the JDBC™ specification, Progress DataDirect has used its expertise to develop the first Pure Java™ JDBC testing tool on the market-DataDirect Test™ for JDBC (DataDirect Test). DataDirect JDBC Test is a free tool included with SequeLink Java Client and DataDirect Connect® for JDBC.

DataDirect Test is a graphical, menu-driven program that allows developers to test JDBC applications. It can also be used as a tool to help developers learn the JDBC API. Its menu items either correspond to specific JDBC functions (for example, connecting to a database or passing a SQL statement) or encapsulate multiple JDBC function calls as a shortcut to perform common tasks (for example, returning a record result). DataDirect Test displays the results of all JDBC function calls and provides fully commented sample Java JDBC code in the same window.

You can run DataDirect JDBC Test as an application on both Windows and UNIX. DataDirect JDBC Test can be used with DataDirect SequeLink Java Client and DataDirect Connect for JDBC drivers.

This document provides some examples of ways that you can use DataDirect Test to test your JDBC applications. For complete information about DataDirect Test and a tutorial for DataDirect Test, refer to either the DataDirect Connect for JDBC User's Guide and Reference.

Test Features

DataDirect Test includes support for the latest JDBC 3.0 specification features. These features include:

  • New JDBC 3.0 DatabaseMetaData methods
  • Support for ParameterMetaData
  • Support for Blob/Clob types
  • Support for updateable result sets
  • Support for Savepoints
  • Connection using JDBC data sources

The DataDirect Test tutorial in the DataDirect Connect for JDBC User's Guide and Reference provides examples of these features.

Executing a Simple Select Statement

Using DataDirect Test, you can execute a simple Select statement. DataDirect Test retrieves and displays the results, and you can examine the JDBC calls that were implemented. For example, you could enter the following Select statement into DataDirect Test:

As a result, DataDirect Test displays the data from the result set:

You can scroll through the code displayed in the Java Code scroll box to see which JDBC calls were implemented by DataDirect Test.

Executing a Prepared Statement

Using DataDirect Test, you can execute a parameterized statement multiple times. For example, in DataDirect Test, you could enter the following SQL Insert statement.

Then, you could set the values and type for each parameter, for example:

After executing the statement, DataDirect Test indicates that one row is inserted and displays the JDBC calls that were implemented.

You can insert multiple records by setting the values and type for each parameter of another record and executing the Insert statement again.

Retrieving Database Metadata

Sometimes you may find it useful to analyze metadata from the database. The metadata also allows you to query the database catalog (enumerate the tables in the database, for example).

When you choose to show metadata, DataDirect Test displays information about the JDBC driver and database to which you are connected. For example:

The metadata also allows you to query the database catalog. In the following example, DataDirect Test queries all tables that are owned by the user SCOTT.

DataDirect Test returns all tables owned by SCOTT.

Scrolling Through a Result Set

Using DataDirect Test, you can scroll through a result set. Note that scrollable result sets are supported by JDBC 2.0 and higher and require a Java 2 Platform (JDK 1.2)-compatible Java Virtual Machine.

To scroll through a result set, first you must specify a result set type and concurrency in DataDirect Test:

Then, you must specify the Select statement you want to execute. For example:

DataDirect Test displays the position of the cursor.

From the Scroll Result Set window (shown above), you can navigate through the result set. After each action, such as Next, DataDirect Test displays the data at the current position of the cursor.

For More Information About DataDirect Test

For complete information about DataDirect Test and a tutorial, refer to either the DataDirect Connect for JDBC User's Guide and Reference.

DataDirect Test for JDBC, developed by DataDirect Technologies, is a powerful tool that allows you to test JDBC applications in either the Windows or UNIX environment. DataDirect Test is a useful tool included with SequeLink Java Client and DataDirect Connect for JDBC.

Connect any application to any data source anywhere

Explore all DataDirect Connectors

Need additional help with your product?

Get Customer Support