Database Usage Notes; Using Perl To Access The Database - Oracle HTTP Server B12255-01 Administrator's Manual

10g release 1 (10.1)
Table of Contents

Advertisement

mod_perl

Database Usage Notes

This section provides information for mod_perl users working with databases. It
explains how to test a local database connection and set character forms.

Using Perl to Access the Database

The following section contains information about using Perl to access the database.
Perl scripts access databases using the DBI/DBD driver for Oracle. The DBI/DBD
driver is part of Oracle Database. It calls Oracle Callable Interface (OCI) to access
the databases.
DBI must be enabled in
following steps:
1.
2.
3.
4.
I
I
Files must be copied to ORACLE_HOME/Apache/Apache/cgi-bin
Example 7–1 Using Perl to Access the Database
#!<ORACLE_HOME>perl/bin/perl -w
use DBI;
my $dataSource = "host=<hostname.domain>;sid=<orclsid>;port=1521";
my $userName = "scott";
my $password = "tiger";
my $dbhandle = DBI->connect("dbi:Oracle:$dataSource", $userName, $password)
print "Content-type: text/plain\n\n";
print "Database connection successful.\n";
### Now disconnect from the database
$dbhandle->disconnect
exit;
7-16 Oracle HTTP Server Administrator's Guide
httpd.conf
Edit httpd.conf using a text editor.
Search for "PerlModule Apache: :DBI".
Uncomment the line "PerlModule Apache: :DBI".
Restart Oracle HTTP Server using the following commands:
UNIX: ORACLE_HOME/opmn/bin> opmnctl [verbose] restartproc
ias-component=HTTP_Server
Windows: ORACLE_HOME\opmn\bin> opmnctl [verbose] restartproc
ias-component=HTTP_Server
or die "Can't connect to the Oracle Database: $DBI::errstr\n";
or warn "Database disconnect failed; $DBI::errstr\n";
for DBI to function. To do this, perform the

Advertisement

Table of Contents
loading

This manual is also suitable for:

Http server

Table of Contents