On Wed, Jul 19, 2006 at 11:23:38AM -0400, Jason Stelzer wrote:
> On Jul 19, 2006, at 10:12 AM, Robert Hicks wrote:
> 
> >Sorry I took so long getting back. What I mean is can I use  
> >Inline::Java to setup a database connection and then pass that  
> >connection off to the Perl side so I don't need to have the Oracle  
> >client installed. I am thinking probably not.
> 
> As long as you're not passing a process boundary or something, it  
> should work. I've done similar things with ejbs. The down side is  
> that you'll be writing some very java looking code (creating  
> iterators, etc). JDBC isn't DBI. [...]

> Your jdbc idea should work similarly, you just cant masquerade its  
> type as easily. Just make the usual jdbc style calls, unmarshall what  
> it returns and use eval as your try. If it were me, I'd just create a  
> perl object that wrapped the reference and stub out the functionality  
> I need. It'd centralize the marshaling/unmarshaling of datatypes as  
> well as error detection.

I'm working on a PDBC module that acts as a layer over my JDBC module
and adds (injects[1]) more DBI-like methods into whatever JDBC classes
are being returned by the JDBC driver.

So, given a JDBC result set handle, you can do things like:

        $row_ref = $rs->fetchrow_array_ref;
        @row = $rs->fetchrow_array;
        $rows_ref = $rs->fetchall_arrayref;
        $hash_ref = $rs->fetchall_hashref($key);
        etc etc.

It's a design experiment related to the DBI<->DBD API for DBI v2.
It's very unoptimised and far from complete at the moment, but is does work.

You can find it at
        http://svn.perl.org/modules/dbi2/trunk/PDBC/
Anyone interested in helping out is *most* welcome.

> Wherever possible I wrap all calls to the jvm in library code that  
> returns perl friendly objects. If you don't, you bleed java style api  
> calls all over your codebase which only amplifies maintenance issues.  
> Then again, I'm working on a fairly large codebase written in perl  
> thats interfacing with several java apps. I wound up creating a  
> library of support code for the app to use when talking to the jvm  
> just to centralize things. The rest of the app uses those objects.

Could you send me a copy of that?

Tim.

[1] Method injection is currently done by some ugly hacks but I hope to
use the Moose module Roles once Moose supports runtime Role composition.

Reply via email to