Perl to Oracle Proxy

0 Likes

This little tool/tip explains how to access an Oracle 8i database from a Perl script running on NetWare 6. Since no native driver is available for netware, the best solution is to use DBD::JDBC for Perl (http://search.cpan.org/~vizdom/DBD-JDBC-0.70/JDBC.pod).

This module works well on NetWare, in conjunction with Oracle's Thin JDBC driver.

To get the Oracle connection up 'n' running, unzip the NWPerlOracle.zip file to the sys volume. It contains the JDBC.pm module and the BER.pm module needed by JDBC.pm.

The zip file also contains a jdbc folder with the neccessary files for the jdbc-perl proxy.

Download the Oracle Thin JDBC driver (classes111.zip) from Oracle (http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/index.html) and put it in the jdbc folder. Then start the proxy by typing "load sys:jdbc/server.ncf" on the console. This can also be added to autoexec.ncf, to start the proxy when the server boots.

When the proxy is running, you can access Oracle from Perl by using DBI to connect to localhost:9001:

use DBI;

my $usrname = '...';
my $passwd = '...';
my $url = '...';

my $connection =
DBI->connect("dbi:JDBC:hostname=localhost:9001;url=$url",$usrname,$passwd)or die "Could not connect!\n";

In the code above, $usrname and $passwd must be a valid Oracle user, and $url must be a valid JDBC connection url.


The above example should also work for other JDBC capable databases, by placing their drivers in sys:jdbc/ and adding them to the class path given in sys:jdbc/server.

Labels:

Collateral
Comment List
Anonymous
Related Discussions
Recommended