Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
I am trying to connect to HSQLDB via Perl using the DBD::JDBC module.
Below is the code snippet i am using.

use DBI;
use DBD::JDBC;
use Data::Dumper;
my $hostname = "xyz";
my $port = 51426;
my $url = "jdbc:hsqldb:hsql://xyz/inmemory_cache";
my $username = "sa";
my $password = "";
my $dbh = DBI->connect("dbi:JDBC:hostname=$hostname:$port;url=$url",$username, $password);

my $sql = "select top 10 * from table";
my $a = $dbh->selectall_arrayref($sql);
print Dumper($a);

I am getting the following error.
DBI connect('hostname=xyz:51426;url=jdbc:hsqldb:hsql://xyz/inmemory_cache','sa',...) failed: I/O Error at experiment.pl line 13

Please note: I am using the HSQLDB and not HSQLDB-BER. Will that make a difference? AFAIK, it shouldnot and I am not able to figure out the reason of the failure.
Please help. This is urgent.
Thanks,
Jasleen

Replies are listed 'Best First'.
Re: DBD::JDBC Connection failing
by ikegami (Patriarch) on Jul 07, 2009 at 19:54 UTC

    hostname=$hostname:$port is wrong. According to the docs, it should be hostname=$hostname;port=$port

    I don't know if there's any other problems.

      I get the same error with hostname=$hostname;port=$port
Re: DBD::JDBC Connection failing
by Anonymous Monk on Jul 08, 2009 at 08:43 UTC
    Add
    #!/usr/bin/perl -- use strict; use warnings; use DBI; DBI->trace(2); # DBI->trace(2 => 'trace.log');
    and copy/paste the trace into <code></code> tags