Friday, June 5, 2009

Perl DBI interface to MySQL

The DBI module can be used to work with databases like Oracle, MySQL, and Informix in Perl. Following is an example to query names and phone numbers in the Info table of Supplier database with MySQL database.

#!/usr/bin/perl

use DBI;
use strict;

my $driver = "mysql";
my $database = "Supplier";
my $source = "DBI:$driver:database=$database";
my $userid = "XXX";
my $password = "XXX";
my $dbh = DBI->connect($source, $userid, $password )
or die $DBI::errstr;

my $sth = $dbh->prepare("SELECT Name, Phone FROM Info");
$sth->execute() or die $DBI::errstr;
print "Company, Phone:\n";
while (my @row = $sth->fetchrow_array()) {
my ($name, $phone ) = @row;
print "$name, $phone\n";
}
$sth->finish();

Wednesday, June 3, 2009

Install Guest Addition for OpenSolaris 2009.06 on VirtualBox 2.2.4

1. Click Devices -> Install Guest Additions to bring up VBOXADDITION 2.2.4 47978 to the Desktop.

2. Start up a terminal then change to the super user. Run "pkgadd -d /media/VBOXADDITION 2.2.4 47978/VBoxSolarisAddition.pkg". Select default and yes to start and continue the installation.

3. Unmount VBOXADDITION 2.2.4 47978 from the desktop.

4. Reboot the system.