On Thu, Jan 13, 2005 at 04:04:57PM -0800, Gennis Emerson wrote:
> I'm trying to get DBD::JDBC functional with the latest DBI release.

Great.

> Architecturally, it's a Perl DBD layer which marshals requests and sends 
> them to a Java server which then uses JDBC to talk to the underlying 
> database. Since I don't know which database is being used, I can't 
> provide database-specific methods via $h->func(jdbc_XXX). In order to 
> enable users to call JDBC methods which don't have an exact DBI 
> equivalent, and to call JDBC driver-specific methods which they know 
> about, I've been using a func/AUTOLOAD combination on the Perl side with 
> reflection on the Java side. A call in Perl looks something like this:
> 
>   $dbh->func("jdbc_getTransactionIsolation");
> 
> Since DBI 1.39, this doesn't work since jdbc_getTransactionIsolation 
> isn't a declared method.

Due to this change I presume:

=head2 Changes in DBI 1.39,    27th November 2003

  Fixed DBI dispatch to not try to use AUTOLOAD for driver methods unless
    the method has been declared (as methods should be when using AUTOLOAD).
    This fixes a problem when the Attribute::Handlers module is loaded.

All you need to do is declare 'stubs' for the methods:

  sub jdbc_getTransactionIsolation;
  sub jdbc_getFoo;
  sub jdbc_setBar;

(Methods in perl must always be pre-declared when using using
AUTOLOAD otherwise you'll get subtle method lookup problems due to
the way the @ISA search is performed twice for AUTOLOAD. See perl docs.)

The stub will resolve the method lookup and then, because it's only
a stub (a declaration without a definition), AUTOLOAD will still
be called for you.

Tim.

Reply via email to