Archive for October, 2007

Solving “LoadError: 14001″ driver errors

Yesterday, there have been a couple of reports of problems with the driver immediately after upgrades to the ibm_db gem version 0.9.0 on Microsoft Windows. The error reported is analogous to the following:

gem 'ibm_db'
require 'mswin32/ibm_db'
LoadError: 14001: The application has failed to start because its side-by-side
configuration is incorrect. Please see the application event log for more detail.

Or in other cases:

LoadError: 14001: This application has failed to start because the application
configurationis incorrect. Reinstalling the application may fix this problem.

If you haven’t received this type of error message, your installation is working and stable. For those few of you who experienced this problem, I want to let you know that this issue is actively being investigated and the proposed solution is being thoroughly tested. Since the error above does not only concern our driver (other applications are raising similar errors on Windows), it appears that the problem is related to the lack or misconfiguration of the VC8 runtime.

Those of you who received an error message, can try to install the Microsoft Visual C++ 2005 Redistributable Package (x86) and try again. This ensures that the VC8 runtime is configured in order to support the new DB2 CLI binary dependencies related to the “native assembly cache (also called WinSxS folder)”. This solved the problem in our preliminary tests. Please use the comments to tell us if this worked for you.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

October 23 2007 | Tips&Tricks | 3 Comments »

Troubleshooting DB2 on Rails

DB2 on Rails provides the developer with many ways to retrieve information about errors which have occurred. Rails developers can take a look at the logs within the log folder in order to read the SQL errors returned by the datasever. But what about simple Ruby scripts? Let’s try to connect to DB2 with the wrong user credentials:

conn = IBM_DB::connect("mydb","myuser","my_wrong_pass")
#=> false

false. That doesn't really help us too much. We know that something went wrong, but we don't exactly know what. Luckily for us, the IBM_DB driver gives us all the tools that we need to properly troubleshoot problems. The example above can be rewritten in this way:

if conn = IBM_DB::connect("mydb","myuser","my_wrong_pass")
  # do something interesting
else
  # conn is false
  raise IBM_DB::conn_errormsg
end
#=> RuntimeError: [IBM][CLI Driver] SQL30082N Security processing failed with reason
"24" ("USERNAME AND/OR PASSWORD INVALID").  SQLSTATE=08001 SQLCODE=-30082

Okay, that should have us covered when it comes to failed attempts to connect to the database, but what about failed queries? Analogously, the IBM_DB driver provides us with the IBM_DB::stmt_errormsg method:

if stmt = IBM_DB::exec(conn, "SELECT * FROM WRONG_TABLE)
  # process the results
else
  # stmt is false
  raise IBM_DB::stmt_errormsg
end
#=> RuntimeError: => [IBM][CLI Driver][DB2/NT] SQL0204N " DB2ADMIN.WRONG_TABLE" is
an undefined name.  SQLSTATE=42704 SQLCODE=-204
    

DB2 error messages are usually easy to understand and with a bit of help from the DB2 Information Center you should be able to get out of trouble most of the time.

DB2 CLI Tracing

Despite the helpful error messages, there are situations in which troubleshooting can be hard because everything seems to be in the right place but your application is still acting up for some reason. The ultimate tool when it comes to troubleshooting for DB2 and Ruby/Rails application problems is to enable DB2 CLI (Call Level Interface) tracing. The CLI trace captures information about applications that access the DB2 CLI driver. Tracing gives you the ability to analyze low level calls to the C driver API with details on the input and output, to and from the database. The resulting trace is not particularly easy to understand for a DB2 novice, but it can offer a microscopic view which is invaluable for understanding problems that are hidden by the abstractions of higher level APIs, and allow you to see to a certain degree what's happening under the hood.

The two free PDFs, Call Level Interface Guide and Reference, Volume 1 and Volume 2 are the best references if you need to look up calls in your CLI trace files. Instructions on how to enable CLI level tracing for DB2 Express-C LUW (Linux/Unix/Windows) can be found here.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

October 19 2007 | How-to and Tips&Tricks | 6 Comments »

IBM_DB gem updated to 0.9.0

Please update your ibm_db ruby gem to the latest version available (0.9.0). From command line run: gem update ibm_db. This fixes an ibm_db 0.8.5 driver incompatibility with the DB2 CLI 9.1 (FixPack 3 and lower), and also addresses a previous issue with the driver crashing on Windows Vista.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

October 17 2007 | Uncategorized | 7 Comments »

DB2onRails.com update

As you may notice from the new look, we decided to switch blogging platforms in order to take advantage of all the powerful features available in Wordpress. As a form of spam prevention, comments are now held for moderation before being published. RSS/Atom feeds should be automatically redirected to Feedburner now, but we strongly recommend that you update your subscription with the new feed and if you wish, you can now receive each post by email. We sincerely hope that you enjoy the new site, which should also be much more reliable.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

October 17 2007 | Announcements | No Comments »