Application Development Guide

Connecting to a Database Using Perl

To enable Perl to load the DBI module, you must include the following line in your DB2 application:

   use DBI;

The DBI module automatically loads the DBD::DB2 driver when you create a database handle using the DBI->connect statement with the following syntax:

   my $dbhandle = DBI->connect('dbi:DB2:dbalias', $userID, $password);

where:

$dbhandle
represents the database handle returned by the connect statement

dbalias
represents a DB2 alias cataloged in your DB2 database directory

$userID
represents the user ID used to connect to the database

$password
represents the password for the user ID used to connect to the database


[ Top of Page | Previous Page | Next Page ]