Displaying DB (db2) Specific Error Message

Most of the developers throws SQLException  from their DB/DAO Layer, and these exception are logged most of the time. The problem in logging SQLException is it doesn't display the exact message or description of the exception, instead it displays only wrapped message.

This article shows how to display DB2 Specific messages from SQLException.

Following code snippets shows how we can display DB2 Specific message. These pattern can be used for any database types.

The SQLExceptionFormator can be extended for any type of database. Following code shows DB2 Specific implementation.