Sunday, April 01, 2007

NetBeans IDE 6.0 M8 is out

I just installed NetBeans IDE 6.0 M8 and noticed that you can start and stop WEBrick within NetBeans now. Before this release, you would have to kill the java task from the task manager which was a pain. I actually didn't use WEBrick within the ide because of this problem. Instead, I just run it from the command line using the native ruby interpreter instead of jruby.

Before I was able to use the WEBrick instance started by NetBeans, I need to setup the project to use the jdbc adapter for MySQL. Since I didn't really bother reading much instruction, I encountered quite a few problems.

Here are the steps I used to get everything working.

1. Modify environment.rb and add these lines in right before Rails::Initializer:

if RUBY_PLATFORM =~ /java/
require 'rubygems'
RAILS_CONNECTION_ADAPTERS = %w(jdbc)
end

Rails::Initializer.run do |config|

2. Modify database.yml to use the jdbc adapter. Of course, instead of test_development, you put your own database name there.

development:
adapter: jdbc
driver: com.mysql.jdbc.Driver
username: root
password: password
url: jdbc:mysql://localhost:3306/test_development

3. Download the JDBC driver for MySQL.
Download Connector/J 5.0
Unzip or untar the archive and copy mysql-connector-java-5.0.5-bin.jar to your jruby-0.9.8\lib.

You can find your jruby-0.9.8 directory under
C:\Documents and Settings\<your username>\.netbeans\

I found this step to be quite important because adding the driver to CLASSPATH did not work for me.

NetBeans also exposed more rake tasks than before.