New support for Rails 2.1

Support for Rails 2.1 has been added to the latest version of the ibm_db gem (0.9.5). To install this version run gem install ibm_db on Windows. On Linux run the following:

$ . /home/db2inst1/db2profile
$ export IBM_DB_DIR=/opt/ibm/db2/V9.5
$ export IBM_DB_LIB=/opt/ibm/db2/V9.5/lib32
$ sudo gem install ibm_db

Adjust these commands for your paths, shell and architecture (e.g. 32 vs. 64 bits).

Please note that at this stage we don’t recommend that you download the outdated Starter Toolkit for DB2 on Rails. Instead, please grab and install DB2 Express-C, install Ruby through the One-Click Installer, install Rails through gems (gem install rails) and then proceed to install the ibm_db gem as explained above. When you install DB2, ensure to select the “Base application development tools” as illustrated here.

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

Posted by Antonio Cangiano | June 26 2008 | Announcements and How-to | 4 Comments »

DB2 and Rails 2.1

Rails 2.1 was released last week at RailsConf 2008, in Portland. Despite being a “minor version” increase from 2.0.2, it introduces quite a few changes. Some of these affect the DB2 adapter, so it is recommended that you don’t upgrade to Rails 2.1 yet.

The API team is fully aware of the outstanding issues and is working on bringing DB2 compatibility to Rails 2.1. An announcement in this blog will be made when a new release is available.

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

Posted by Antonio Cangiano | June 06 2008 | Announcements | 3 Comments »

Ruby for building Yahoo! BrowserPlus services?

There has been much discussion (if you can call it that) in the Ruby on Rails community regarding a need for using applications while disconnected. I happen to be believe that despite the proliferation of connectivity options, ability to use web applications off-line is absolutely crucial. So, I’ve been looking at various technologies for taking web applications off-line. I am a big fan of Adobe Flex partly because it can be used to produce web-based applications that run on Adobe Air. I’ve also been watching Google Gears (now unbranded from Google). Just a few days back Yahoo went for a “Sneak Peek” availability of their BrowserPlus. So, I decided to install Yahoo BrowserPlus and give it a try with a few Yahoo properties that use it today.

I tried the FlickrUploader demo and go this dialog. This is actually expected and it is a good thing. Basically, what this means is that FlickrUploader needs these services and BrowserPlus is offering me to activate them:

Ruby is now in Yahoo! BrowserPlus

This dialog suggests that FlickrUploader needs Ruby.  I presume that this is because FlickrUploader is written at least in part using Ruby? After a bit more reading I am getting a feeling that we will be able to use Ruby to add extra functions and services to BrowserPlus. At least that is implied by all of the info I was able to find on the subject. Unfortunately, BrowserPlus is still in the “Sneak Peak” release mode (Yahoo must of run out of Greek letters) so it is not possible to try to add BrowserPlus capability to anything but a Yahoo operated site in Ruby or otherwise. I do however like the direction in which BrowserPlus seems to be heading and I love the fact that they chose to support Ruby.

Oh yeah, almost forgot to mention … at this point in time it is more of a promise than reality. I tried to activate the RubyInterpreter service and got “Not compatible”:

RubyInterpreter not compatible message in Yahoo BrowserPlus

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

Posted by Leon Katsnelson | June 03 2008 | Musings | No Comments »

The status of DB2 and Rails 2.x

I’d like to take a moment to provide a small status update on what’s been going on in the DB2 on Rails world. The Alphaworks starter toolkit hasn’t been update for a long time, so someone may wrongly assume that the project is not maintained, but nothing could be further from the truth. The toolkit will be updated in order to provide a Windows one click install alternative sometime in the near future, but the real action these days has moved to Rubyforge.

The development and improvement of the IBM_DB Ruby driver and ActiveRecord adapter is considered a priority and there is continuos work carried out by the API development team. In fact, another important update for the ibm_db gem was released just yesterday. The gem makes the installation and upgrade process very straightforward on both Windows and Linux. If you’ve already installed a previous version through RubyGems, all you have to do in order to upgrade to the current 0.9.4 version, is run: gem update (with sudo if on Linux/Unix).

The new gem fixes a few bugs and, more interestingly, adds support for XML columns in Rails 2 style migrations. This means that you can define tables that take advantage of pureXML, with the new “sexy migration” syntax. Here is an example:

class CreateCustomers < ActiveRecord::Migration
  def self.up
    create_table :customers do |t|
      t.string :name
      t.xml :info

      t.timestamps
    end
  end

  def self.down
    drop_table :customers
  end
end

Concisely, the main message is: DB2 works with Rails 2, it’s supported by IBM and there are many customers who are successfully using it for their projects.

You may not be able to use minor conveniences (like rake db:create), given that these aren’t implemented for DB2 by the Rails team, but that won’t affect your ability to use DB2 on Rails. That said, on a side note, I started working on a Rails plugin called DB2 Extended in order to simplify the development process for you, and add DB2 specific functionalities to the framework. It’s a personal project, not an IBM one, and it’s still in its infancy, but feel free to take advantage of it and contribute with your own patches.

It’s all about you

The API team efforts would be wasted if they weren’t focused on what really interests you. It is therefore important that you let us know about your experiences with the DB2 on Rails stack, send us your feedback, be it encouragingly kind words or frustrated ones.

If you discover a bug, it’s crucial that you log a ticket on Rubyforge. And if you are unsure about it being an actual bug please don’t be shy, and feel free to start a discussion thread on the fora. We thank you in advance for your partecipation.

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

Posted by Antonio Cangiano | May 02 2008 | Announcements | 1 Comment »

Essential guide for the Ruby driver

In the past couple of months, I received a fairly large number of requests about how to use the IBM_DB Ruby driver to query DB2. So I decided to create an essential guide for using the Ruby DB2 driver. Amongst the topics I covered, there are: connecting to the database (local or remote), executing queries, retrieving connection and execution errors, fetching results, using prepared statements for parameterized queries and finally how to use the driver for dealing with stored procedures. That should be more than enough to get your started with the driver and, even if it’s about Ruby and not Rails, it will be beneficial to those who develop DB2 on Rails applications.

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

Posted by Antonio Cangiano | February 08 2008 | How-to | No Comments »

How to setup the Ruby driver for DB2 on Linux

Yesterday I wrote a short guide to setting up DB2 9.5, Ruby and the IBM_DB driver on Linux (32 or 64 bits), and published it on my personal blog. I didn’t host it on DB2onRails.com since it also covers the installation of the newly released Python driver, a subject somewhat off-topic for this blog. That said, the step-by-step instructions provided for Ubuntu 7.10 may be very useful to many of our Ruby users following this blog. If you’re experiencing problems with the installation of DB2 9.5 or the ibm_db Ruby gem on Linux, check out Guide to setting up the IBM Ruby and Python drivers for DB2 on Linux (32 or 64 bit) for help.

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

Posted by Antonio Cangiano | November 15 2007 | How-to | 1 Comment »

New version of DB2 Express-C is out

Just in time for halloween, we released a new version of DB2. If you are in to instant gratification, you can get DB2 Express-C v9.5 immediately from http://www.ibm.com/db2/express . I am not going to provide a detailed description of what is new in this version but I will say that if you were impressed with DB2 pureXML before you will be absolutely amazed what you can do with XML in DB2 v9.5 and DB2 Express-C includes pureXML at no charge, naturally. Oh, and it is all available to a Ruby on Rails programmer.

If you like running your database servers on Linux then you will really like DB2 Express-C v9.5. DB2  engine on Linux now uses threaded (as opposed to process) model of execution. This means that your database server will now use a lot less memory and you will be doing a lot less figuring out how to set it up for optimum memory utilization. In v9.5 you can replace a dozen or so memory tuning parameters with a single one. While threaded engine is new to Linux, DB2 for Windows has always been threaded. Less time to tune database server means more time to spend writing really cool Ruby on Rails applications with DB2. Oh, and I almost forgot … you no longer have to be root to install DB2 on Linux.

If you like counting money (and who doesn’t), there is a new datatype which is really good. It is called DECFLOAT and it allows you to do money arithmetic without loosing any of it in rounding. The really cool thing is that if you run DB2 Express-C on Linux on POWER 6servers (System p or System i) you have hardware assist right in silicone that makes these operations blazingly fast. We will have to wait for Intel and AMD to put decimal arithmetic in to their silicone. Intel, AMD, are you listening?

If you are building applications that deal with credit card data (here we go with the money again), or need to comply with privacy legislation or need to do anything to identify the actual originator of a transaction and record all actions performed in an audit log then you are also in luck with DB2 v9.5. Let’s say you are building a online store application and will want to accept credit cards. You may not know it yet, but your application will have to comply with something called PCI DSS. An whether you know it or not, if you can’t prove that you comply, your merchant account will be revoked so unless you figured out a way of how to take cash on the web, you will be out of business. I am not going to describe the exact details of how DB2 helps you comply with PCI but I say that being able to identify the end user completing a transaction rather then some proxy id you are using to connect from your code in to the database is the key component of it. Another important aspect is beign able to record everything that is going on in an audit log that can be reviewed and shown to the auditor when asked. Oh, and DB2 can encrypt data both in database and on the wire but believe it or not, the first two features I talked about are actually more important for achieving compliance and staying in business. And these features apply to more then just PCI DSS. The same requirements exist for complying with privacy and corporate governance legislation.

There are also a lot of new functions that make DB2 run faster and make it more scalable like optimistic locking. Then there is a raft of functions that make it easier to manage, back up and recover if need be. There is also a brand new and, you guessed it, free IBM Data Studio for building database objects, working with XML and creating web services (both SOAP and RESTfull) but I will save these topics for another post.

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

Posted by Leon Katsnelson | November 01 2007 | Announcements and Uncategorized | 2 Comments »

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]

Posted by Antonio Cangiano | 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]

Posted by Antonio Cangiano | 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]

Posted by Antonio Cangiano | October 17 2007 | Uncategorized | 7 Comments »

« Prev - Next »