Example 7 16   MySQL database connection with the Mysql.pm interface
use Mysql;
my $host="localhost";
my $database="itsodb";
my $user="itsosj";
my $password="itsosj";
$dbh = Mysql >connect($host,$database,$password,$user);
The corresponding DBI connection to a DB2 database is quite similar. Instead of 
the 
use Mysql
, the DBI interface and the DBD::DB2 driver have to be defined. If 
DB2 constants are used (e.g. SQL_MODE_READ_ONLY in the connection 
attributes, etc.) this has to be announced to the Perl interpreter by including 
 use 
DBD::DB2::Constants 
 in the Perl program (see Example 7 17).
Example 7 17   DB2 database connection with DBI interface
use DBI;
use DBD::DB2::Constants;
use DBD::DB2;
my $user="itsosj";
my $password="itsosj";
$dbh = DBI >connect("dbi:DB2:itsodb2", $user, $password);
As DB2 is more powerful than MySQL, the connect statement may require a 
fourth argument 
\%attr
 which contains the connection attributes as shown in 
Example 7 18.
$dbh=DBI >connect($data_source, $user,$password, \%attr)
;
Example 7 18   DB2 specific connection attributes
db2_access_mode      SQL_MODE_READ_ONLY or SQL_MODE_READ_WRITE
db2_clischema        Character string
db2_close_behavior   SQL_CC_NO_RELEASE or SQL_CC_RELEASE
db2_connect_node     Integer (must be set in DBI >connect method; it cannot be 
 modified afterwards)
db2_current_schema   Character string
db2_db2estimate      Integer
db2_db2explain       One of:
                         SQL_DB2EXPLAIN_OFF
                         SQL_DB2EXPLAIN_SNAPSHOT_ON
                         SQL_DB2EXPLAIN_MODE_ON
                         SQL_DB2EXPLAIN_SNAPSHOT_MODE_ON
db2_info_acctstr     Character string
db2_info_applname    Character string
db2_info_userid      Character string
 Chapter 7. Application porting 
175






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved