Recent Posts

Installing DB2 on ubuntu

By Tze Yong Koh → Saturday, October 17, 2015

1. Uncomment the Partner repository lines by editing the /etc/apt/sources.list file
Look for the word "partner" in the file /etc/apt/sources.list
Uncomment the line for (by removing the "#") character
# deb lucid partner
# deb-src lucid partner
If your Ubuntu release is not lucid, add in the two lines above into the sources.list file

2. Update the package list
$ sudo apt-get update

3. Install DB2 using apt-get
$ sudo apt-get install db2exc


Backup and Restore DB2 to Another Machine

By Tze Yong Koh →

Use db2look to export DDL and db2move to export data.

The name of the database is "mydb" as an example
On source machine:
$ mkdir migrate
$ cd migrate
$ db2look -d mydb -e -a -o db2look.sql
$ db2move mydb export
$ cd ..
$ tar cf migrate.tar migrate
$ gzip migrate.tar

Transfer migrate.tar.gz to destination machine.
Note: Make sure that the database is created.
If not create it with the following:
Create database [db name, eg:mydb]

On destination machine:
$ gunzip migrate.tar.gz
$ tar xf migrate.tar
$ cd migrate
$ db2 -tvf db2look.sql
$ db2move mydb load

You may encounter -668 error when your application runs on the restored database. You can fix that with SET INTEGRITY.

If you have cyclic dependencies of the tables when you are trying to do SET INTEGRITY, the solution is at this post "Solving cyclic dependency for DB2 SET INTEGRITY".


Solving cyclic dependency for DB2 SET INTEGRITY

By Tze Yong Koh → Wednesday, October 14, 2015

While I am trying to resolve -668 error for DB2, the solution is to set integrity on the related tables.
However, I ended up trying to set integrity on a set of tables with cyclical dependencies. So the command 
SET INTEGRITY for <table> immediate checked
does not work.

Searching more, I found that the solution is actually the same command, but all the dependent table should be comma separated. Something like the below.

SET INTEGRITY for table_a, table_b, table_c immediate checked

Hope this helps!

DB2 SQL Error: SQLCODE=-668. Fixed with SET INTEGRITY

By Tze Yong Koh → Tuesday, October 13, 2015

After I migrated my DB2 data to a new machine, I encountered "DB2 SQL Error: SQLCODE=-668".
At first, I thought that I can do a table reorg to fix it.  However, when I issue the reorg command, the same error code -668 was returned.

After some searching, the solution is to set integrity for the affected tables.

1. To find all the affected tables.
select 'set integrity for '||rtrim(tabschema)||'.'||tabname||' immediate checked' from syscat.tables where status = 'C'

2. Copy and paste the generated statements into db2 console.

3. Repeat a few times to clear all the tables so that the SQL from step 1 returns no more row.

Note, you may experience cyclic dependency on your tables that you are not able to clear. You can check out this post on cyclical dependencies and set integrity for db2.

Snap Circuits Alternative Energy Green, from Amazon

By Tze Yong Koh → Monday, October 12, 2015

I have previously given "Snap Circuits Jr. SC-100 Electronics Discovery Kit" as presents and it was very well received.

So this time round, I thought that the kids can have and extension to their base "Snap Circuits Jr. SC-100 Electronics Discovery Kit" and learn about alternative energy.

The original set shipped in free from Amazon without any issues. However, for the Snap Circuit Alternative Energy set,  I was not able to select the free international shipping, even though this product appear when I have selected "International Shipping" and "Free International Shipping".

So I contacted Amazon's customer service for support, the customer service explained that there is a limit to the size of the package for free international shipping which "Snap Circuit Alternative Energy" set exceeds.

Then I asked politely, if there is anything that the customer service can do to help me with this. And the customer service graciously offered to waive the shipping for me! Woo Hoo!
Thank you Amazon.

Moving Docker's Directory

By Tze Yong Koh → Sunday, October 11, 2015

We have an AWS instance that is running docker images. The AWS instance came with 8 GB of free space and we have mounted another data partition of 100 GB.

However, by default, the docker images are consuming space from within the 8 GB, which will not be sufficient, so we have got to move docker directory to the data partition that was mounted. The following steps worked for me.

  1. Default directory /var/lib/docker
  2. Stop docker service and move docker to data partition (in this case is "/data", you can mount your data partition anywhere, just replace "/data" with what you have)
    $ sudo stop docker
    $ sudo mv /var/lib/docker /data/docker
  3. Edit docker config, look for DOCKER_OPTS, add "-g /data/docker". Docker config can be found at /etc/default/docker.

    Final DOCKER_OPTS should be similar to the following:
    $ cat /etc/default/docker
    # Use DOCKER_OPTS to modify the daemon startup options.
    DOCKER_OPTS="--dns --dns -g /data/docker"
  4. Start docker service.

JDK8 java.lang.NoClassDefFoundError: com/sun/tools/javac/code/TypeTags

By Tze Yong Koh →

Java build fail after update to jdk8 java.lang.NoClassDefFoundError: com/sun/tools/javac/code/TypeTags

Some projects continue to build successfully while some others failed after upgrading JDK.
Looking deeper into it and comparing the projects, those that failed are projects that are using lombok. It has been a while since I have upgraded lombok version. (which was still at 0.XXX)

After downloading the latest version of lombok and rebuild, the build completes successfully!