CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
Connecting to Oracle using JDBC

 



lost_in_perl
New User

Sep 15, 2006, 3:33 AM

Post #1 of 2 (3018 views)
Connecting to Oracle using JDBC Can't Post

Hi Guys,

Complete noob here so bare with me. Looking to write a simple script to connect to our Oracle database using JDBC drivers. Can you tell me if my syntax is correct here please?


Code
 #! /usr/bin/perl -w 
use DBI;
my $url = 'jdbc:oracle:thin:@buku:1521:tst01';
my $user = "test";
my $password = "test2717";
my $dbh = DBI->connect("dbi:JDBC:hostname=$hostname;port=$port;url=$url",
$user, $password)
or die("failed to connect: $DBI::errstr");


I have my JDBC driver on the classpath and can connect using the same URL from a simple Java application so I know it works.

I get the following when I run my script.


Code
DBI connect('hostname=buku;port=1521;url=jdbc:oracle:thin:@buku:1521:tst01','jira',...) failed: I/O Error   at /usr/local/bin/db_connect.pl line 12 
failed to connect: I/O Error at /usr/local/bin/db_connect.pl line 12.




Thanks guys.

(This post was edited by lost_in_perl on Sep 15, 2006, 6:37 AM)


davorg
Thaumaturge / Moderator

Sep 18, 2006, 4:08 AM

Post #2 of 2 (3008 views)
Re: [lost_in_perl] Connecting to Oracle using JDBC [In reply to] Can't Post

I'm afraid that I know nothing about DBD::JDBC but a quick scan of the documentation reveals that in the opinion of the author "The expected use for this module is as a DBI interface to databases with JDBC drivers but no DBI drivers". So given that Oracle has perfectly servicable DBD drivers (see DBD::Oracle) it's a bit strange to use the JDBC drivers instead.

Having said that this section of the documentation seems to explain what you need to do to connect to a remote server.

--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives