7.2.1  Converting MySQL Perl applications to DB2 UDB
Two interfaces between Perl and the MySQL database have to be considered 
when discussing application porting form MySQL to DB2. First is 
Mysql.pm
, a 
custom interface that works only with MySQL. The other newer interface is a 
plug in for the Database Independent (DBI) set of modules. DBI provides a 
common Perl API for all database accesses and enables greater portability. The 
DBI interface is the most robust and standard. However, many legacy systems 
still use the Mysql.pm interface to connect to MySQL. In fact, the MySQL 
interface Mysql.pm is currently implemented as an emulation on top of the DBI 
drivers. The interface for accessing DB2 is the DBI interface with the DBD::DB2 
driver. Information about and how to install the DBI interface and the DBD::DB2 
driver can be found at the following Web sites:
http://www.ibm.com/software/data/db2/perl/
http://www.perl.com/CPAN/modules/by module/DBD/
http://aspn.activestate.com/ASPN/Modules/
As applications using the DBI interface to connect to MySQL generally can be 
adapted to DB2 by simply changing the database driver from 
DBD::Mysql
 to 
DBD::DB2
; this section only discusses the application conversion from Mysql.pm 
to DBI interface.
Converting Mysql.pm to DBI interface supported code
The interface documentation is normally installed with the appropriate module in 
the 
perl 
directory. More detailed information about the interface and the provided 
functions can be found there.
Connecting database
With Mysql.pm, five different connect statements can be used to connect to a 
database in a MySQL server:
$dbh = Mysql >Connect;
$dbh = Mysql >Connect($host);
$dbh = Mysql >Connect($host,$database);
$dbh = Mysql >Connect($host,$database,$password);
$dbh = Mysql >Connect($host,$database,$password,$user);
The connect statement needs the host name, database name, user ID, and 
password. The first four statements assume some or all connection information 
from the environment. If no 
$database
 parameter is given, a 
SelectDB
 statement 
has to be provided to connect to a database. In Example 7 16 the 
connect 
syntax to a MySQL database is shown. For simplicity reasons the error handling 
is not included in following examples.
174 
MySQL to DB2 UDB Conversion Guide






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