Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

DBI Error

by kprasanna_79 (Hermit)
on Mar 22, 2007 at 21:24 UTC ( [id://606108]=perlquestion: print w/replies, xml ) Need Help??

kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

Hi revered Monks,

I have the following DBI error. Can you through some light on this...

use DBI; my $dbh = DBI->connect(["dbi:Oracle:ppp","pp1","pp2"]); $dbh->disconnect; print "Database connect success\n";
Error i am getting is Can't connect to data source ARRAY(0x4001396c), no database driver spe +cified and DBI_DSN env var not set at - line 2
-Prasanna.K

Replies are listed 'Best First'.
Re: DBI Error
by marto (Cardinal) on Mar 22, 2007 at 21:32 UTC
    You are not connecting properly, [] is for an array reference, not an array. Try something like:
    use strict; use warnings; use DBI; my $dbh = DBI->connect( 'dbi:Oracle:ppp','marto','martossecretpassword +') || die "Database connection not made: $DBI::errstr"; $dbh->disconnect();
    Check out the DBD::Oracle documentation for further examples.

    Martin
Re: DBI Error
by jettero (Monsignor) on Mar 22, 2007 at 21:28 UTC
    That's an easier fix than you might be thinking. In perl, [] is for array references and () is for arrays. See perlreftut for further info on the difference.

    Update: I was just reading through the perlreftut, since I link to it fairly often. That's a good read even if you're a avid perl nerd already.

    -Paul

Re: DBI Error
by Mr. Muskrat (Canon) on Mar 23, 2007 at 17:06 UTC
    jettero and marto have already given you the answer you need but I thought that I would comment on it more as an aside. In documentation, square braces are often used to annotate optional parameters.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://606108]
Approved by jettero
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found