Share & Learn

Friday, June 22, 2007

Ruby and Java, the new theme for our generation

JRuby is a 100% pure-Java implementation of the Ruby programming language that runs in the JVM.

Lets exhibit this use of JRuby by establishing a type 4 connectivity using mysql database ( mysql db is popular from yahoo to NASA).

1. Create a database user in mysql
Download type 4 pure JDBC driver (http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.1.10.zip/from/pick)
Unzip JDBC driver to C:/default folder.
copy the file mysql-connector-java-3.1.10-bin.jar to the lib folder of your Java installation.
add this .jar file location to your Classpath

2. Create a table under the user in mysql
3. Just fire some insert queries on that table.
4. Connect to MySQL using JRuby ( Using the concepts of modules)
There can be name clashes between Java class names and Ruby class names. To resolve this name clash, a ruby module which holds the java class.

I will be posting my code in the my next post ( Be sure to check that out

blog comments powered by Disqus
blog comments powered by Disqus