Connecting to MySQL using Ruby within NetBeans

Now this one is really buggy! I’ve spend 4 hours looking for a solution. Looking at the web left me in anguish thinking about the fact that no forum had such a straightforward solution that I mustered using the famous “Hit-And-Trial” algorithm. Alright, too much of gyaan I know but here is what the error looked up like initially:

#!/usr/bin/ruby -w
require “dbi”
..some code

require no such file to load dbi


C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/dbi-0.4.3/lib/dbi.rb:318:in `load_driver': Could not load driver (uninitialized constant MysqlError) (DBI::InterfaceError)
from C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/dbi-0.4.3/lib/dbi.rb:160:in `_get_full_driver'
from C:/Program Files/Ruby/lib/ruby/gems/1.8/gems/dbi-0.4.3/lib/dbi.rb:145:in `connect'
from C:\Users\owner\Documents\NetBeansProjects\Ruby\Learning\lib\main.rb:9

1. Although NetBeans is integrated with Ruby, kindly install the latest environment from

2. Click Tools -> Ruby Platforms within NetBeans IDE. Add a platform as shown below
Add Ruby Platform

3. Go to Project -> Properties -> Run and select the latest version of Ruby as shown below:

4. Compile the program and you are all set.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s