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

We have a scaled down version of the script , test.pl, that just executes the connect and fails with the following error.

DBI connect('55zosV8','DAKPM',...) failed: (SQL-S1000) (SQL-S1000)(DBD: db_login/SQLConnect err=-1) at /opt/isv/sqlnk_client +/5_50_00/test/test.pl line 17 Couldn't connect to database: (SQL-S1000) (SQL-S1000)(DBD: db_login/SQLConnect err=-1) at /opt/isv/sqlnk_client +/5_50_00/test/test.pl line 17.

Here's the test.pl script

$cat test.pl #!/opt/isv/perl5.8.0/bin/perl use DBI; my $server_name='55zosV8'; my $user='DAKPM'; my $password='xxxxxxxx'; my $dbh = DBI->connect('DBI:ODBC:55zosV8',$user,$password) or die "Couldn't connect to database:" . DBI->errstr; print "opened database connection\n";

What am I doing wrong?

Thanks for your help.

20070125 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: DBI connection
by ferreira (Chaplain) on Jan 25, 2007 at 14:58 UTC

    The usual question is: can you connect to this same database via other tools? The dsn is correctly setted and working? The documentation is your friend always: DBI, DBD::ODBC.

    And please add code tags to make your question more legible.

Re: DBI connection
by logie17 (Friar) on Jan 25, 2007 at 15:55 UTC
    Are you able to connect via ODBC with any other clients? Also check out the FAQ on DBD::ODBC. Also what sort of platform are you trying to connect to and what sort of machine is the script being ran on? Hope this leads you in the right direction.

    Thanks,
    s;;5776?12321=10609$d=9409:12100$xx;;s;(\d*);push @_,$1;eg;map{print chr(sqrt($_))."\n"} @_;
Re: DBI connection
by PreferredUserName (Pilgrim) on Jan 25, 2007 at 18:04 UTC
    "ODBC" is just a client-side interface; you still need a driver that implements it, and talks whatever wire protocol your database server can understand.

    Assuming you're talking to DB2 on a z/OS host, you need something that will talk the DRDA wire protocol. There are no functional free drivers that do that, to my knowledge.

    You probably want to buy DB2-Connect for whatever flavor of Unix/Linux you're using: http://www-306.ibm.com/software/data/db2/db2connect/

    Then you can just install DBD::DB2 from CPAN, and connect with DBI->connect("dbi:DB2:55zosV8", "DAKPM", $pass)

    PS: Good luck! You'll need it, since DB2 on z/OS is *freaking* *horrible*! :(