Sunday, March 31, 2013

DB2 Error messages in SquirrelSQL

SquirrelSQL is a great tool for working with databases. However, I had a bit of trouble running queries against DB2 databases. When a query had a syntax problem (or encountered any other error during execution), it would just show me the SQL Error Code, not the human-readable error string.

There's an easy way to fix that:

In the connection alias, add a property that says:
  retrieveMessagesFromServerOnGetMessage=true

jdbc:db2://<server>:<port>/<db-name>:retrieveMessagesFromServerOnGetMessage=true;
Excerpt from the DB2 infocenter:
"During a connection to a data server, set the retrieveMessagesFromServerOnGetMessage property to true if you want full message text from an SQLException.getMessage call."
  http://pic.dhe.ibm.com/infocenter/db2luw/v10r1/index.jsp