-
Book Overview & Buying
-
Table Of Contents
IBM DB2 9.7 Advanced Application Developer Cookbook
We can directly embed SQL SAVEPOINT commands to implement savepoints in SQLJ. Let's see how to do it.
We will implement savepoints in SQLJ using the same example as before.
We will use the same table TEST_SVPT created in the previous example. We can use the following command to create it:
CREATE TABLE TEST_SVPT (
EMPNO INTEGER,
EMPNAME VARCHAR(20),
MGRNO INTEGER);
In this example, we will create a transaction having multiple savepoints and we will see how to use them:
1. Creating a connection object and a connection context: Before we can execute any SQL statement against the database, we first need to set up the database connection. To do that, we need to load the database driver and then create a connection object:
Use the Class.forName() method to load the database driver:
Class.forName("com.ibm.db2.jcc.DB2Driver ").newInstance();
Use the getConnection() method to get the connection:
String url = "jdbc:db2:sample";
Connection con...
Change the font size
Change margin width
Change background colour