How do you connect to database in perl

Showing Answers 1 - 3 of 3 Answers

Manjusha1

  • May 17th, 2006
 

There is DBI module.use DBI;my $dbh = DBI->connect('dbi:Oracle:orcl', 'username', 'password',)where username and password is yours. THis is exmaple for oracle database.Hope this helps,Manjusha

  Was this answer useful?  Yes

suseel

  • May 18th, 2006
 

Helo Manjusha,

I  have used the same code you have given but it is giving error like this :

Program is :

use DBI;            # Load the DBI module

### Perform the connection using the Oracle driver
 $dbh = DBI->connect( "dbi:Oracle:orcl", "scott",
                        "tiger" )
    or die "Can't connect to Oracle database: $DBI::errstr\n";

exit;

Error is :

install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC contains
: C:/Perl/lib C:/Perl/site/lib .) at (eval 4) line 3.
Perhaps the DBD::Oracle perl module hasn't been fully installed,
or perhaps the capitalisation of 'Oracle' isn't right.
Available drivers: DBM, ExampleP, File, Proxy, Sponge.
 at D:\perl programs\db.pl line 7

  Was this answer useful?  Yes

max1x

  • May 20th, 2006
 

You to install the appropriate driver for DB so that the connection can be make, just like ODBC drivers for each DB interface are needed...

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions