binf-jw has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am trying to remotely to connect to a database using DBI::ProxyServer, DBD::Proxy and DBD::mysql drivers.

The server is running on a Redhat perl, v5.8.8 built for i386-linux-thread-multi and the client is perl, v5.10.0 built for MSWin32-x86-multi-thread

I start the ProxyServer on the linux:
$ dbiproxy --configfile config.cfg

And have the follow code to test a connection
#!usr/bin/perl use strict; use warnings; use DBI; use DBD::Proxy; use DBD::mysql; # Configuration options to connect my %config = ( host => 'xx.xx.xx.xx', port => #####, driver => 'mysql', database => 'xxx', user => 'xxx', auth => xxxxxxxxxxxxxxxxxx, ); # Create Data Source $ENV{DBI_AUTOPROXY} = "hostname=$config{host};port=$config{port};"; my $dsn = "DBI:mysql:database=xxx"; # Connect / Create database handle my $dbh = DBI->connect( $dsn, $config{user}, $config{auth} ) || die $D +BI::errstr; # Prepare query my $sth = $dbh->prepare('SHOW TABLES'); # Execute query and fetch results $sth->execute(); my $tables_ref = $sth->fetchall_arrayref(); # Works fine $dbh->disconnect;

The code correctly retieves a list of tables in the required database. However the following non-fatal error occurs

Client side error:

DBD::Proxy::db connected failed: Server returned error: Failed to execute method CallMethod: Not permitted f method connected of class DBI::ProxyServer::db at /usr/lib/perl5/site_perl/5.8.8/RPC/PlServer.pm line 326.


dbiproxy debug call:
I've tried debugging the dbiproxy and found where the problem is:
CallMethod: => DBI::ProxyServer::db=HASH(0xa150170),connected,DBI:mys +ql:database=xxx,xxx,xxxxxxxxxxxxxxx CallMethod died with: Not permitted for method connected of class DBI: +:ProxyServer::db at /usr/lib/perl5/site_perl/5.8.8/RPC/PlServer.pm li +ne 326.

The documentation metions a known issue with Unproxied method calls, Thinking that perhaps this was it and sub connected; wasn't added I opened up the source code for DBD::Proxy package DBD::Proxy::db but alas it wasn't the problem.

Since then i've been searching for a sollution and have only found one bug post on it Debian Bug Post

I was wondering if any one knows what is going wrong ( or what I have done wrong ) and if there is an easy sollution.

I'm also aware you only need DBD::Proxy for drivers which don't support remote connection. And seeing as DBD::mysql as options for a host and port ( couldn't get it to work with dbi:mysql:xxx;host=xx.xx.xx.xx;port=#####;) perhaps I don't need DBD::Proxy at all?

Could it be a problem with different versions of perl (5.8.8 and 5.10) or even releases of DBI::Proxy?

Many Thanks,
John

Replies are listed 'Best First'.
Re: DBI::Proxy non-fatal connection error
by Anonymous Monk on Nov 04, 2008 at 15:13 UTC
    Wild guess, but try adding connected on the server side
    sub DBI::ProxyServer::db::connected;
    your error does say DBI::ProxyServer::db
      Can't believe I missed that.
      But yes that was the error:

      Fixed: Accepted Methods are stored as follows in DBI::ProxyServer:
      $o->{'XXX_methods'} = { 'DBI::ProxyServer' => { 'Version' => 1, 'NewHandle' => 1, 'CallMethod' => 1, 'DestroyHandle' => 1 }, 'DBI::ProxyServer::db' => { 'prepare' => 1, 'commit' => 1, 'rollback' => 1, 'STORE' => 1, 'FETCH' => 1, 'func' => 1, 'quote' => 1, 'type_info_all' => 1, 'table_info' => 1, 'disconnect' => 1, }, 'DBI::ProxyServer::st' => { 'execute' => 1, 'STORE' => 1, 'FETCH' => 1, 'func' => 1, 'fetch' => 1, 'finish' => 1 } };


      Add
      'connected' => 1,
      To the hash_ref:
      'DBI::ProxyServer::db' => { 'connected' => 1, 'prepare' => 1, 'commit' => 1, 'rollback' => 1, 'STORE' => 1, 'FETCH' => 1, 'func' => 1, 'quote' => 1, 'type_info_all' => 1, 'table_info' => 1, 'disconnect' => 1, },

      Just restart the proxy and that's it!
      Thanks AM

      John,