IBM DB2 Computer Accessories User Manual


 
234 DB2 Deployment Guide
@REM -----------------------------------------------------------
@REM Step 4.b
@REM -----------------------------------------------------------
:success
db2 -o- -l populatedb.log connect reset
exit /b 0
Step 1:
Connect to the database. The user ID and password are passed to the script
as the input parameters.
Step 2:
Once connected, we execute each of the files containing the SQL statements
to populate our database. Notice that we use the command line processor
option -c- that turn off the autocommit.
Step 3:
We have to commit the transaction because we turned off the autocommit.
Step 4.a:
In case of an error, we rollback the transaction and reset the connection to the
database.
Step 4.b:
If all the inserts are successful, we just reset the database connection.
Using an application
Because there is no difference in executing DDL or SQL statements in a Java
application, we can reuse our Java applications described in 5.2.3, “Using an
application” on page 228. We supplied two command scripts, jstmt.cmd and
jstmt.cmd for running the Java application. Jstmt.cmd is used to execute DDL or
SQL statements while jscript.cmd is used to execute a shell script. Example 5-13
shows how to run these two scripts.
Example 5-13 Run the Java sample applications
# Step A : Start Java application that executes a set of sql statements
c:> jstmt populate.sql
# Step B : Start Java application that executes a shell script
c:> jscript popoulatedb
For a more comprehensive description of how to use the scripts, see 5.6,
“Samples overview” on page 251.