DbFit


DB2

Contributed by Mike Patrick

Why are there multiple DB2 adapters?

There are essentially three flavors of DB2:

Each flavor comes with its own peculiarities. There are driver differences:

And system differences:

Which DB2 adapter should I use?

Setup Script to run Acceptance Tests

Two of the functions required for the Acceptance Tests need their syntax modified for DB2. DB2 does not support AUTO_INCREMENT or CONCAT taking three arguments. They are:

CREATE TABLE USERS(NAME VARCHAR(50) UNIQUE,
                   USERNAME VARCHAR(50),
                   USERID INT NOT NULL
                              GENERATED ALWAYS AS IDENTITY
                              (START WITH 1, INCREMENT BY 1))

and

CREATE FUNCTION ConcatenateF
  (firststring varchar(100),
   secondstring varchar(100))
RETURNS varchar(200)
  RETURN CONCAT(firststring, concat(' ', secondstring))

DB2 for System i Considerations

Choosing a driver

Which JDBC driver should I use?

Using the default database

If the default database (often the tables of interest to our testing) must be journalled, acceptance tests with INSERT and UPDATE operations may fail with:

java.sql.SQLException: [SQL7008] TEST_DBFIT in TESTLIB not valid for operation. Cause . . . . . :   
The reason code is 3.  Reason codes are: 1 -- TEST_DBFIT has no members. 2 -- TEST_DBFIT has been saved with storage free. 3 -- TEST_DBFIT not journaled, no authority to the journal, or the journal state is *STANDBY.  
Files with an RI constraint action of CASCADE, SET NULL, or SET DEFAULT must be journaled to the same journal.

There are two ways around this:


blog comments powered by Disqus