The DBD::DB2 driver is developed and maintained by IBM. The source is available from CPAN under an open-source license.
DBD::DB2 closely follows the DBI standard, with a few extensions:
- Connection and statement attributes for transaction isolation levels, iSeries accounting strings, etc.
- Support for binding binary large object (BLOB) data types.
- Ability to process multiple result sets returned from a CALL to a single stored procedure.
Cataloged connection with DBD::DB2
#!/usr/bin/perl
use DBI;
my $username = 'lynn';
my $password = '5tuff';
my $database = 'MYDB';
my $conn = DBI->connect("dbi:DB2:$database", $username, $password,
{ AutoCommit => 1} );
Uncataloged connection with DBD::DB2
#!/usr/bin/perl
use DBI;
my $username = 'lynn';
my $password = '5tuff';
my $hostname = 'localhost';
my $port = 1527;
my $database = 'MYDB';
my $DSN = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=$database;"
. "HOSTNAME=$hostname;PORT=$port;PROTOCOL=TCPIP";
my $conn = DBI->connect("dbi:DB2:$DSN", $username, $password,
{ AutoCommit => 1} );