TOTD #3: Using JavaDB with JRuby on Rails
By arungupta on Aug 19, 2007
In a previous screencast, I showed how to develop a Rails application fetching data from the MySQL database and deploy it in GlassFish. GlassFish comes pre-bundled with JavaDB. Based upon a user request, this TOTD shows to use JavaDB database instead of MySQL.
Here are the steps required to replace MySQL database configuration with JavaDB. You can either mix these steps with the existing screencast or follow these steps altogether after the original app is created using MySQL.
- Copy "
GLASSFISH_HOME/javadb/lib/derbyclient.jar" to "
C:\\Program Files\\NetBeans 6.0M10\\ruby1\\jruby-1.0\\lib" (or the directory location where JRuby for NetBeans 6 is installed). Make sure NetBeans IDE is restarted after the jar file is copied.
- In your application, change development database
configuration in "
The NetBeans IDE comes pre-configured with the database URL, username and password used in this configuration.
- Start JavaDB using "
asadmin start-database" command.
db:migraterake target to create the database required by the application. The development database configuration is used to create the database tables. If you followed the screencast, then a new table "
greetings" is created in the database "
- Change production database configuration in "
production:This new database configuration is exactly the same as for the development configuration. The production configuration is used by the WAR file.
Insert value into the newly create database as "
insert into GREETINGS values (1, 'Hello from JavaDB');".
- Create the WAR file using
- Deploy the WAR file in the "
You can also check out an early version of a tutorial that is being written about installing and configuring Ruby support in the NetBeans IDE. If you would like to get early access to Ruby documentation, learn more here.
Please leave suggestions on the TOTD that you'd like to see. A complete archive is available here.