Thursday, August 20, 2009

Shutdown Hook and Eclipse

If you would like to get shutdown hook to execute on a process launched from Eclipse, by clicking the red stop button, it won't be called. Here is the reported Eclipse bug, which is opened since 2003-05-23, and the Resolution is WONTFIX. :)



Tuesday, July 28, 2009

How to Add/Deploy WAR file into Eclipse Tomcat Server

In some scenario, you wish to deploy a default web application into Eclipse Tomcat which is not part of your project, you may just add the war file into the below directory:

%your_workspace%\.metadata\.plugins\org.eclipse.wst.server.core\tmpX\webapps

where tmpX could be tmp0, tmp1 etc





Wednesday, March 11, 2009

Why My Java Program Shows Wrong Timestamp?

It may due to you set up time zone wrongly if you are in Solaris or Unix machine. For the below example, if you use GMT[+/-] format instead of City or a valid timzone name, you will got wrong timestamp. Refer to my previous post about how to set TZ correctly.


fwsst36 scadm$ echo $TZ;date;date -u;java DateUtils
CST6CDT
Tue Mar 10 03:53:35 CDT 2009
Tue Mar 10 08:53:35 GMT 2009
Tue Mar 10 03:53:35 CDT 2009


fwsst36 scadm$ echo $TZ;date;date -u;java DateUtils
Asia/Jakarta
Tue Mar 10 15:54:05 WIT 2009
Tue Mar 10 08:54:05 GMT 2009
Tue Mar 10 15:54:05 WIT 2009


fwsst36 scadm$ echo $TZ;date;date -u;java DateUtils
GMT-7
Tue Mar 10 15:54:26 GMT 2009
Tue Mar 10 08:54:26 GMT 2009
Tue Mar 10 01:54:26 GMT-07:00 2009
(This is wrong)




How To Set Time Zone (TZ) Correctly in a Unix/Solaris System?

First, check your environ manual:

> man -s5 environ
...
TZ

Timezone information. The contents of this environment
variable are used by the functions ctime(3C),
localtime(3C), strftime(3C), and mktime(3C) to override
the default timezone. The value of TZ has one of the two
formats (spaces inserted for clarity):

:characters

or

std offset dst offset, rule

If TZ is of the first format (that is, if the first
character is a colon (:)), or if TZ is not of the second
format, then TZ designates a path to a timezone database
file relative to /usr/share/lib/zoneinfo/
, ignoring a
leading colon if one exists.
...

Second, check is your city is under /usr/share/lib/zoneinfo.


csdbld03: zoneinfo> find . -name Kuala_Lumpur
./Asia/Kuala_Lumpur

Third, update TZ at your /etc/TIMEZONE. Example TZ=Asia/Kuala_Lumpur.

Avoid to use GMT[+/-] format as it is obsolete.
> cat /usr/share/lib/zoneinfo/src/README
...
The following files have been removed from the release:

/usr/share/lib/zoneinfo/GMT-12
/usr/share/lib/zoneinfo/GMT-11
/usr/share/lib/zoneinfo/GMT-10
/usr/share/lib/zoneinfo/GMT-9
/usr/share/lib/zoneinfo/GMT-8
/usr/share/lib/zoneinfo/GMT-7
/usr/share/lib/zoneinfo/GMT-6
/usr/share/lib/zoneinfo/GMT-5
/usr/share/lib/zoneinfo/GMT-4
/usr/share/lib/zoneinfo/GMT-3
/usr/share/lib/zoneinfo/GMT-2
/usr/share/lib/zoneinfo/GMT-1
/usr/share/lib/zoneinfo/GMT+1
/usr/share/lib/zoneinfo/GMT+2
/usr/share/lib/zoneinfo/GMT+3
/usr/share/lib/zoneinfo/GMT+4
/usr/share/lib/zoneinfo/GMT+5
/usr/share/lib/zoneinfo/GMT+6
/usr/share/lib/zoneinfo/GMT+7
/usr/share/lib/zoneinfo/GMT+8
/usr/share/lib/zoneinfo/GMT+9
/usr/share/lib/zoneinfo/GMT+10
/usr/share/lib/zoneinfo/GMT+11
/usr/share/lib/zoneinfo/GMT+12
/usr/share/lib/zoneinfo/GMT+13
...




Monday, February 23, 2009

How to solve error "Informix -567: Cannot write sorted rows"?

Try to get the related ISAM error (Follow this for JDBC). If it is "2: No such file or directory", look for your DBSPACETEMP or PSORT_DBTEMP value (via onstat -g env or onstat -c). Ensure the folder points by DBSPACETEMP or PSORT_DBTEMP exists.






Monday, November 03, 2008

How To Check Is Your Informix Server Shutdown Gracefully?

Compare the first set of Informix log:

20:28:34 Checkpoint Completed: duration was 1 seconds.
20:28:34 Checkpoint loguniq 1, logpos 0xd40018, timestamp: 0xf638
20:28:34 Maximum server connections 1
20:28:35 IBM Informix Dynamic Server Stopped.
20:28:36 IBM Informix Dynamic Server Started.

Sat Oct 11 20:28:36 2008

20:28:36 Event alarms enabled. ALARMPROG = '/usr/informix/etc/log_full.sh'
20:28:36 Booting Language from module <>
20:28:36 Loading Module
20:28:36 Booting Language from module <>
20:28:36 Loading Module
20:28:41 DR: DRAUTO is 0 (Off)
20:28:41 IBM Informix Dynamic Server Version 10.00.UC7 Software Serial Number AAA#B000000
20:28:43 IBM Informix Dynamic Server Initialized -- Shared Memory Initialized.

20:28:43 Physical Recovery Started at Page (1:2283).
20:28:43 Physical Recovery Complete: 0 Pages Examined, 0 Pages Restored.
20:28:43 Logical Recovery Started.
20:28:43 10 recovery worker threads will be started.
20:28:46 Logical Recovery has reached the transaction cleanup phase.
20:28:46 Logical Recovery Complete.
0 Committed, 0 Rolled Back, 0 Open, 0 Bad Locks

20:28:46 Dataskip is now OFF for all dbspaces
20:28:47 Checkpoint Completed: duration was 0 seconds.
20:28:47 Checkpoint loguniq 1, logpos 0xd41018, timestamp: 0xf648

20:28:47 Maximum server connections 0
20:28:47 On-Line Mode


and second set of log:

19:11:22 Maximum server connections 39
19:16:22 Fuzzy Checkpoint Completed: duration was 0 seconds, 4 buffers not flushed.
19:16:22 Checkpoint loguniq 5, logpos 0x2c63080, timestamp: 0x4958f6

19:16:22 Maximum server connections 39
No stopped message listed. The engine did not shutdown cleanly.
19:23:37 IBM Informix Dynamic Server Started.

Tue Oct 21 19:23:39 2008

19:23:39 Event alarms enabled. ALARMPROG = '/usr/informix/etc/log_full.sh'
19:23:40 Booting Language from module <>
19:23:40 Loading Module
19:23:40 Booting Language from module <>
19:23:40 Loading Module
19:23:56 DR: DRAUTO is 0 (Off)
19:23:56 IBM Informix Dynamic Server Version 10.00.UC7 Software Serial Number AAA#B000000
19:23:59 IBM Informix Dynamic Server Initialized -- Shared Memory Initialized.

19:23:59 Physical Recovery Started at Page (1:4321).
19:23:59 Physical Recovery Complete: 0 Pages Examined, 0 Pages Restored.
19:23:59 Logical Recovery Started.
19:23:59 10 recovery worker threads will be started.
19:24:02 Logical Recovery has reached the transaction cleanup phase.
19:24:02 Logical Recovery Complete.
21 Committed, 0 Rolled Back, 0 Open, 0 Bad Locks

19:24:04 Dataskip is now OFF for all dbspaces
19:24:04 (11) connection rejected - no calls allowed for sqlexec
19:24:04 listener-thread: err = -27002: oserr = 0: errstr = : No connections are allowed in quiescent mode.

19:24:04 (13) connection rejected - no calls allowed for sqlexec
19:24:04 listener-thread: err = -27002: oserr = 0: errstr = : No connections are allowed in quiescent mode.

19:24:05 Checkpoint Completed: duration was 1 seconds.
19:24:05 Checkpoint loguniq 5, logpos 0x2c69018, timestamp: 0x4959d3

19:24:05 Maximum server connections 0
19:24:05 On-Line Mode


The first one came right to online mode in 11 seconds. If you look at the log you will see the engine was stopped right before restarting it. When the engine is stopped, all transactions are cleaned up. They are either rolled back or committed and the physical log is also cleared out. If you look at the second startup, there was no clean shutdown, This was due to someone killing the oninit process or perhaps the OS getting rebooted. Regardless the engine was still performing work. When the engine was restarted, it discovered that there were open transactions that needed to be dealt with . This explains the additional time it took to come online. The 27002 errors were due to users trying to connect before the engine was ready for them. The engine is working as designed.



Tuesday, July 29, 2008

How to enable Informix ISAM/RSAM error in JDBC?

You will not able to get Informix RSAM / ISAM error with normal SQLException. ISAM error is important to find the real database problem. For example, if an SQLCODE message says that a table cannot be created, the RSAM message states the reason, which might be insufficient disk space. You need to get the nested/chained exception via SQLException.getNextException(). Code example is at Java Developers Almanac.