Database Reference
In-Depth Information
DBI uses the string “Oracle” to build the case-sensitive name of the driver module. The
driver module for connecting to ORACLE instances is DBD::Oracle not DBD::oracle —thus the
error. Other driver modules exist for most database products on the market. DBD::ODBC is a
driver that works with any database product that supports ODBC (Open Database Connectivity).
Connecting Through the Bequeath Adapter
When connecting to a DBMS instance using the bequeath adapter, make sure the environment
variables ORACLE_HOME (mandatory on UNIX systems, optional on Windows) and ORACLE_SID are
set. The following two lines of Perl code suffice to connect:
use DBI;
$dbh = DBI->connect("DBI:Oracle:", "ndebes", "secret") or die "Connect failed:
$DBI::errstr";
On Windows systems, the following exception is thrown when ORACLE_SID is not set correctly:
Connect failed: ORA-12560: TNS:protocol adapter error (DBD ERROR: OCIServerAttach).
The error indicates that the Windows service, which implements the ORACLE DBMS
instance, is not running. The Windows service may be started with the command net start
OracleService ORACLE_SID . On UNIX, the error is different, since there are significant dispar-
ities between the architecture of the ORACLE DBMS on UNIX and Windows (multi-process
architecture with shared memory on UNIX vs. single process, threaded architecture on Windows).
$ export ORACLE_SID=ISDOWN
$ perl dbi.pl
DBI connect('','ndebes',...) failed: ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory (DBD ERROR: OCISessionBegin) at dbi.pl
line 5
$ unset ORACLE_SID
$ perl dbi.pl
DBI connect('','ndebes',...) failed: ORA-12162: TNS:net service name is incorrectly
specified (DBD ERROR: OCIServerAttach) at dbi.pl line 5
By the way, V$SESSION.SERVICE_NAME always has the default value of SYS$USERS when
connecting through the bequeath adapter.
Connecting Through the IPC Adapter
Use of the IPC protocol implies that the DBMS instance, the listener, and the client are running
on the same system. An entry in the configuration file listener.ora for a listener supporting
only the IPC protocol might look as follows:
LISTENER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = TEN))
)
)
 
Search WWH ::




Custom Search