PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > What is the best way to interact with a JDBC database
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
What is the best way to interact with a JDBC database

Réponse
 
LinkBack Outils de la discussion
Vieux 03/12/2007, 23h51   #1
Venks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut What is the best way to interact with a JDBC database

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Hi,

I have a database that has only JDBC connectivity but I need to interact to
this database from Ruby. What's the best way to do so? All ideas and
suggestions are welcome.

My initial thought is to create a Java program that accepts connection
information and a SQL statement and execute the SQL against the database.
Assuming that I have this program, what's the best way to call this Java
program from Ruby?

I looked at JRuby and didn't feel that's the right answer.

Regards,

-Venks

  Réponse avec citation
Vieux 04/12/2007, 00h43   #2
Dan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Just out of interest, what was your problem with JRuby?

I had a similar issue with an Oracle RDB database running on VMS that only
has .NET (beta) and JDBC drivers. So I went with JRuby using
activerecord-jdbc and it has been working rather well for me. A few minor
issues here and there, but nothing major.


On Dec 4, 2007 9:21 AM, Venks <venkatesh.mantha@gmail.com> wrote:

> Hi,
>
> I have a database that has only JDBC connectivity but I need to interact
> to
> this database from Ruby. What's the best way to do so? All ideas and
> suggestions are welcome.
>
> My initial thought is to create a Java program that accepts connection
> information and a SQL statement and execute the SQL against the database.
> Assuming that I have this program, what's the best way to call this Java
> program from Ruby?
>
> I looked at JRuby and didn't feel that's the right answer.
>
> Regards,
>
> -Venks
>


  Réponse avec citation
Vieux 04/12/2007, 01h51   #3
Venks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

It's a science/research project called "MonetDB".

On Dec 3, 2007 6:37 PM, Deepak Vohra <dvohra09@yahoo.com> wrote:

> Which database is it?
>
> Venks <venkatesh.mantha@gmail.com> wrote: Hi,
>
> I have a database that has only JDBC connectivity but I need to interact
> to
> this database from Ruby. What's the best way to do so? All ideas and
> suggestions are welcome.
>
> My initial thought is to create a Java program that accepts connection
> information and a SQL statement and execute the SQL against the database.
> Assuming that I have this program, what's the best way to call this Java
> program from Ruby?
>
> I looked at JRuby and didn't feel that's the right answer.
>
> Regards,
>
> -Venks
>
>


  Réponse avec citation
Vieux 04/12/2007, 01h57   #4
Venks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Actually, I haven't tried Jruby except reading about it. I am using Ruby as
a glue to put together all the tasks I need including Database access, File
I/O and all the stuff that comes with a heavy duty batch programming. It's
my understanding that JRuby doesn't provide all the classes and I would like
to avoid using JRuby just for this requirement of accessing a JDBC database.


On Dec 3, 2007 6:43 PM, Dan <dan.macdaddy+ruby@gmail.com> wrote:

> Just out of interest, what was your problem with JRuby?
>
> I had a similar issue with an Oracle RDB database running on VMS that only
> has .NET (beta) and JDBC drivers. So I went with JRuby using
> activerecord-jdbc and it has been working rather well for me. A few minor
> issues here and there, but nothing major.
>
>
> On Dec 4, 2007 9:21 AM, Venks <venkatesh.mantha@gmail.com> wrote:
>
> > Hi,
> >
> > I have a database that has only JDBC connectivity but I need to interact
> > to
> > this database from Ruby. What's the best way to do so? All ideas and
> > suggestions are welcome.
> >
> > My initial thought is to create a Java program that accepts connection
> > information and a SQL statement and execute the SQL against the

> database.
> > Assuming that I have this program, what's the best way to call this Java
> > program from Ruby?
> >
> > I looked at JRuby and didn't feel that's the right answer.
> >
> > Regards,
> >
> > -Venks
> >

>


  Réponse avec citation
Vieux 04/12/2007, 02h17   #5
Reid Thompson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Venks wrote:
> It's a science/research project called "MonetDB".
>
> On Dec 3, 2007 6:37 PM, Deepak Vohra <dvohra09@yahoo.com> wrote:
>
>> Which database is it?
>>
>> Venks <venkatesh.mantha@gmail.com> wrote: Hi,
>>
>> I have a database that has only JDBC connectivity but I need to interact
>> to
>> this database from Ruby. What's the best way to do so? All ideas and
>> suggestions are welcome.
>>
>> My initial thought is to create a Java program that accepts connection
>> information and a SQL statement and execute the SQL against the database.
>> Assuming that I have this program, what's the best way to call this Java
>> program from Ruby?
>>
>> I looked at JRuby and didn't feel that's the right answer.
>>
>> Regards,
>>
>> -Venks
>>
>>

>

from the website...There are application bindings for MonetDB/SQL using JDBC,
ODBC, PHP, Python, Perl and C,... so you could probably work the C binding into
Ruby in some fashion.



  Réponse avec citation
Vieux 04/12/2007, 17h07   #6
Thomas Enebo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Venks wrote:
> Actually, I haven't tried Jruby except reading about it. I am using Ruby as
> a glue to put together all the tasks I need including Database access, File
> I/O and all the stuff that comes with a heavy duty batch programming. It's
> my understanding that JRuby doesn't provide all the classes and I would like
> to avoid using JRuby just for this requirement of accessing a JDBC database.
>
>

Out of personal interest...Which classes are missing for you in JRuby?
We have an interest in filling in gaps in our implementation.

-Tom

> On Dec 3, 2007 6:43 PM, Dan <dan.macdaddy+ruby@gmail.com> wrote:
>
>
>> Just out of interest, what was your problem with JRuby?
>>
>> I had a similar issue with an Oracle RDB database running on VMS that only
>> has .NET (beta) and JDBC drivers. So I went with JRuby using
>> activerecord-jdbc and it has been working rather well for me. A few minor
>> issues here and there, but nothing major.
>>
>>
>>

--
Thomas E Enebo <thomas.enebo@sun.com>
JRuby Core Developer, http://www.bloglines.com/blog/ThomasEEnebo


  Réponse avec citation
Vieux 04/12/2007, 22h26   #7
Venks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

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.

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).
- 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.
- Once I am done with the Jruby module, I will continue further processing
using regular Ruby modules.

Does this makes sense?

Thanks,


On Dec 4, 2007 11:07 AM, Thomas Enebo <Thomas.Enebo@sun.com> wrote:

> Venks wrote:
> > Actually, I haven't tried Jruby except reading about it. I am using Ruby

> as
> > a glue to put together all the tasks I need including Database access,

> File
> > I/O and all the stuff that comes with a heavy duty batch programming.

> It's
> > my understanding that JRuby doesn't provide all the classes and I would

> like
> > to avoid using JRuby just for this requirement of accessing a JDBC

> database.
> >
> >

> Out of personal interest...Which classes are missing for you in JRuby?
> We have an interest in filling in gaps in our implementation.
>
> -Tom
>
> > On Dec 3, 2007 6:43 PM, Dan <dan.macdaddy+ruby@gmail.com> wrote:
> >
> >
> >> Just out of interest, what was your problem with JRuby?
> >>
> >> I had a similar issue with an Oracle RDB database running on VMS that

> only
> >> has .NET (beta) and JDBC drivers. So I went with JRuby using
> >> activerecord-jdbc and it has been working rather well for me. A few

> minor
> >> issues here and there, but nothing major.
> >>
> >>
> >>

> --
> Thomas E Enebo <thomas.enebo@sun.com>
> JRuby Core Developer, http://www.bloglines.com/blog/ThomasEEnebo
>
>
>


  Réponse avec citation
Vieux 04/12/2007, 22h57   #8
Thomas Enebo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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 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 <thomas.enebo@sun.com>
JRuby Core Developer, http://www.bloglines.com/blog/ThomasEEnebo


  Réponse avec citation
Vieux 05/12/2007, 00h53   #9
Venks
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Note: parts of this message were removed by the gateway to make it a legal Usenet post.

Hi,

- I am using the MySQL Driver which has one-to-one correspondence to "C"
API. I may need to have more control on how I access MySQL. It's my
understanding that Active record is based on DBI interface and has an
additional layer.
- The system calls I mentioned below are not File I/O. I am using the File
I/O class too. But the system calls I am referring is directly calling OS
commands as I use "sed, "gpg", "zip" and some other UNIX utilities.

Now here is question which I am sure you are not reading/listening for the
first time.

Are there any performance issues between Ruby and JRuby (I know this has
been asked many times but couldn't find any definitive answer/article)

Thanks,

On Dec 4, 2007 4:57 PM, Thomas Enebo <Thomas.Enebo@sun.com> wrote:

> 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 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 <thomas.enebo@sun.com>
> JRuby Core Developer, http://www.bloglines.com/blog/ThomasEEnebo
>
>
>


  Réponse avec citation
Vieux 05/12/2007, 06h45   #10
Ken Bloom
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

On Mon, 03 Dec 2007 17:51:59 -0500, Venks wrote:

> Note: parts of this message were removed by the gateway to make it a
> legal Usenet post.
>
> Hi,
>
> I have a database that has only JDBC connectivity but I need to interact
> to this database from Ruby. What's the best way to do so? All ideas and
> suggestions are welcome.
>
> My initial thought is to create a Java program that accepts connection
> information and a SQL statement and execute the SQL against the
> database. Assuming that I have this program, what's the best way to call
> this Java program from Ruby?
>
> I looked at JRuby and didn't feel that's the right answer.


Well, if you're going to have Ruby call a Java program and you can't port
the whole thing over to JRuby, you should consider running a DRb server
in JRuby to access the database, and access that from a native ruby DRb
client. I think (hope) you should be able to expose the JDBC objects you
need having to code any special wrappers for them.

--Ken
(I have never programmed this kind of arrangement before, so I don't know
what JRuby can or can't do. This is just speculation.)

--
Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu/~kbloom1/
  Réponse avec citation
Vieux 05/12/2007, 18h36   #11
Thomas Enebo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What is the best way to interact with a JDBC database

Venks wrote:
> Hi,
>
> - I am using the MySQL Driver which has one-to-one correspondence to "C"
> API. I may need to have more control on how I access MySQL. It's my
> understanding that Active record is based on DBI interface and has an
> additional layer.
>

Well the issue with using the MySQL Driver is that it requires a native
C extension to work. Currently, JRuby does not support C extensions.
Your code will either have to use the pure Ruby MySQL driver (not very
fast) or start using JDBC directly. So this unfortunately will require
extra work.
> - The system calls I mentioned below are not File I/O. I am using the File
> I/O class too. But the system calls I am referring is directly calling OS
> commands as I use "sed, "gpg", "zip" and some other UNIX utilities.
>

We can call out using system and friends. I think there is a couple of
bugs with bi-directional communication using popen, but I suspect things
will work for you here.
> Now here is question which I am sure you are not reading/listening for the
> first time.
>
> Are there any performance issues between Ruby and JRuby (I know this has
> been asked many times but couldn't find any definitive answer/article)
>

No real performance issues. We have a few bottlenecks which could
surface, but we are faster in many areas and slower in some others. All
in all our performance is looking really good.

-Tom
> Thanks,
>
> On Dec 4, 2007 4:57 PM, Thomas Enebo <Thomas.Enebo@sun.com> wrote:
>
>
>> 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 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 <thomas.enebo@sun.com>
>> JRuby Core Developer, http://www.bloglines.com/blog/ThomasEEnebo
>>
>>
>>
>>

>
>



--
--
Thomas E Enebo <thomas.enebo@sun.com>
JRuby Core Developer, http://www.bloglines.com/blog/ThomasEEnebo


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h48.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,82808 seconds with 19 queries