From: Thomas Enebo Date: 2007-12-05T06:57:52+09:00 Subject: Re: What is the best way to interact with a JDBC database Venks wrote: > I don't know if any classes are missing. I was just reading the > documentation that suggested that all the classes may not be > available. Also, I have not used JRuby yet (As a matter of fact I am new to > Ruby let alone developing in a OO language environment) > > Thanks for all the feedback. I was thinking whether SOAP may be an option, > but could be over kill just for bridging the gap between Ruby and Java. > My main comment is that JRuby "is" Ruby in the sense that you can write as much Ruby as you want and JRuby is capable of running it. So write your app in Ruby and execute/run it in JRuby. We are meant to be a drop-in alternative to Ruby. So I would not think so much as things being a JRuby module or a Ruby Module. The caveat to that last sentence is that in addition to being able to run Ruby in JRuby you can also access/use Java classes from within JRuby. So code in Ruby and bring in the Java classes you need into your app (in this case JDBC) to do what you need in all your databases. OR.... Install activerecord-JDBC gem and then use activerecord APIs to interact with your databases. This does have one limitation that we only support the more popular databases at this point. Less known ones will not work (though we are looking for help in adding support to more databases). The main benefit is that this will end up making your code Java-free (behind the scenes our gem is using Java code, but it is transparent to you). > I will try to use Jruby to access the JDBC database. Please allow me to > specify in few steps to describe the overall picture of my batch job: > > - I have a bunch of Ruby modules that access many MySQL databases across > several machines. > - I also have lot of System calls to create data into files which I then I > transfer between different databases (not just MySQL). > A question? When you say system calls to create data into files, do you just mean using things like Ruby's File class? That is no problem if so. > - Somewhere in this process I need to invoke a method from a module that's > developed using JRuby. > - When I invoke the JRuby module, I except the Java environment to be > active, otherwise I don't need JVM. > I recommend just running your whole Ruby application in JRuby. > - Once I am done with the Jruby module, I will continue further processing > using regular Ruby modules. > > Does this makes sense? > > Thanks, > -Tom -- Thomas E Enebo JRuby Core Developer, http://www.bloglines.com/blog/ThomasEEnebo