skip to main content
DataDirect tools : DataDirect Test : DataDirect Test tutorial : Executing a prepared statement
  

Try DataDirect Drivers Now
Executing a prepared statement
This example explains how to execute a parameterized statement multiple times.
To execute a prepared statement:
1. From the Connection window menu, select Connection / Create Prepared Statement. DataDirect Test prompts you for a SQL statement.
2. Type an Insert statement and click Submit. Then, click Close.
Get Prepared Statement SQL window with SQL statement
3. Select Statement / Set Prepared Parameters. To set the value and type for each parameter:
a. Type the parameter number.
b. Select the parameter type.
c. Type the parameter value.
d. Click Set to pass this information to the JDBC driver.
Set Prepared Statement Parameters window with type and value information
4. When you are finished, click Close.
5. Select Statement / Execute Stmt Update. The JDBC/Database Output scroll box indicates that one row has been inserted.
Connection window showing record has been updated
6. If you want to insert multiple records, repeat Step 3 and Step 5 for each record.
7. If you repeat the steps described in "Executing a simple Select statement," you will see that the previously inserted records are also returned.
Connection window showing table with new record