Setting up DBI and DBD::Oracle on Solaris

Using DBI and DBD::Oracle

Make sure to only use the /usr/local/bin/perl interpreter on Solaris machines. To allow the interpreter to see the newly installed libraries, add these statements right after the #!/usr/local/bin/perl line to your Perl scripts:

use lib qw(/home/username/perl/lib/site_perl/5.8.2/sun4-solaris);
use lib qw(/home/username/perl/lib/sun4-solaris/);

use DBI;
use DBD::Oracle;
Where again, username is your own useraname.

To connect to the database, use these statements:

my ($db_username) = "username";
my ($db_password) = "password";
my ($db_host) = "server9.engr.scu.edu";
my ($db_sid) = "dc81";

        $dbh = DBI->connect("dbi:Oracle:host=$db_host;sid=$db_sid",
			$db_username, $db_password,
			{RaiseError => 1, AutoCommit => 1});
(Leave db_host and db_sid as is, but make sure to change db_username and db_password to reflect the settings for your own Oracle account). Use of DBI itself is beyond the scope of this document, but documentation should be readily available at google. O'Reilly Publishing's Perl Cookbook also contains several excellent DBI examples.

Back to Aleksandr Feinberg's homepage.

This page is created with vi

The content of these web pages is not generated by and does not represent the views of Santa Clara University or any of its departments or organizations.