How to use Perl's DBI connect when no mysql passwd is set?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use Perl's DBI connect when no mysql passwd is set?
Prev   Next
# 1  
Old 06-12-2009
Can't call method "prepare" on an undefined value at...

I am getting the error "Can't call method "prepare" on an undefined value at..." with the following code:

<code>my %dbh;
my $dbh = DBI->connect("DBI:mysql:Customer_Data",
$username,
$password
) or die "Database connection failed.";

$myquery="SELECT * from Site";
$execute = $connect->prepare($myquery);
$execute->execute() or die $dbh->errstr;
</code>

Can anyone suggest what might be the problem?

Last edited by vincaStar; 06-12-2009 at 07:09 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Oracle DBI through Apache problem

Experts, I've been struggling with making a Perl Oracle DBI script to work through my Apache webserver. Mysql DBI scripts work fine, but I'm having issue's with Oracle. The oracle script works on command line, but I'm getting an "Internal Server Error" with apache Sourcing the oracle... (0 Replies)
Discussion started by: timj123
0 Replies

2. Shell Programming and Scripting

Perl: connect to network devices, run set of commands

I am trying to write a script for my own use that will allow me to connect to network devices, then run a set of commands. I start with a list of ips in a text file. Each ip is on its own line. I start with a second file of commands. Each command on one line. for illustration .. the cmd.txt... (2 Replies)
Discussion started by: popeye
2 Replies

3. Shell Programming and Scripting

Perl DBI error

Hi All, I installed DBI module in a non INC location and using it in my script via "use lib". But it throw the below error at the "use DBI" step. Please help Usage: DBI::_install_method(dbi_class, meth_name, file, attribs=Nullsv) at /xx/xxx/xxxxx/xxxxx/oracle/lib/DBI.pm/oracle/lib/DBI.pm line... (2 Replies)
Discussion started by: prasperl
2 Replies

4. Shell Programming and Scripting

perl: help with DBI

Hi there, I have a bit of code similar to below (which ive actually got from perldoc, but mine is similar enough) $sth = $dbh->prepare(q{ SELECT region, sales FROM sales_by_region }); $sth->execute; my ($region, $sales); # Bind Perl variables to columns: $rv =... (4 Replies)
Discussion started by: hcclnoodles
4 Replies

5. UNIX for Advanced & Expert Users

Perl's DBI Module on OS X - uninstallable?

i've been struggling with installing the Perl DBI & DBD modules all weekend, and I'm getting close, but no cigar as of yet. When I run the perl script db.pl I get the following mismatch error: Mon Apr 19 09:43:29 EDT 2010 /Library/Perl/DBD-mysql-4.011 -> peterv@MBP17.local<515>$: db.pl | tee... (0 Replies)
Discussion started by: peterv6
0 Replies

6. Solaris

DBI with MySQL client library compile on Solaris

how dow you complie perl module DBI with mysql from /usr/local/mysql/bin keeps going to mysql client for /usr/sfw/bin is it the LD_PATH ???...:confused: error is # perl login.cgi DBI connect('customers;mysql_socket=/tmp/mysql.sock:localhost','root',...) failed: Client does not... (1 Reply)
Discussion started by: photon
1 Replies

7. Shell Programming and Scripting

connect to MySQL from Perl using DBI

Hi, I want to connect perl with the mysql to select and so on but the connection don't work code #!/usr/bin/perl BEGIN { # PERL MODULES WE WILL BE USING use DBI; $dbh = DBI->connect('DBI:mysql:C:\Program Files\MySQL\MySQL Server 5.0\data\db1','','pass') or die $DBI::errstr;} #... (1 Reply)
Discussion started by: eng_shimaa
1 Replies

8. Shell Programming and Scripting

Installing Perl DBI and DBD

Hi, i have some queries on installing the Perl DBI and the DBD Oracle. I know that i have to install the DBI first. I have the source files in a folder in my home directory.The commands to install arecd /home/DBI Perl Makefile.PL make make installI would like to know, after executing these... (4 Replies)
Discussion started by: new2ss
4 Replies

9. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

10. Shell Programming and Scripting

PERL DBI module install

We ran into an issue trying to install DBI and DB2 modules for perl for AIX from the link http://www-306.ibm.com/software/data/db2/perl/ We tried to install the DBI module using bash# perl -MCPAN -e 'install DBI' command. However we ended up with the following error. Stop. ... (3 Replies)
Discussion started by: jerardfjay
3 Replies
Login or Register to Ask a Question
DBIx::Connector::Driver(3pm)				User Contributed Perl Documentation			      DBIx::Connector::Driver(3pm)

Name
       DBIx::Connector::Driver - Database-specific connection interface

Description
       Some of the things that DBIx::Connector does are implemented differently by different drivers, or the official interface provided by the
       DBI may not be implemented for a particular driver. The driver-specific code therefore is encapsulated in this separate driver class.

       Most of the DBI drivers work uniformly, so in most cases the implementation provided here in DBIx::Connector::Driver will work just fine.
       It's only when something is different that a driver subclass needs to be added. In such a case, the subclass's name is the same as the DBI
       driver. For example the driver for DBD::Pg is DBIx::Connector::Driver::Pg and the driver for DBD::mysql is DBIx::Connector::Driver::mysql.

       If you're just a user of DBIx::Connector, you can ignore the driver classes.  DBIx::Connector uses them internally to do its magic, so you
       needn't worry about them.

Interface
       In case you need to implement a driver, here's the interface you can modify.

   Constructor
       "new"

	 my $driver = DBIx::Connector::Driver->new( $driver );

       Constructs and returns a driver object. Each driver class is implemented as a singleton, so the same driver object is always returned for
       the same driver.  The "driver" parameter should be a Perl DBI driver name, such as "Pg" for DBD::Pg or "SQLite" for DBD::SQLite. If a
       subclass has been defined for $driver, then the object will be of that class.  Otherwise it will be an instance of the driver base class.

   Instance Methods
       "ping"

	 $driver->ping($dbh);

       Calls "$dbh->ping". Override if for some reason the DBI driver doesn't do it right.

       "begin_work"

	 $driver->begin_work($dbh);

       Calls "$dbh->begin_work". Override if for some reason the DBI driver doesn't do it right.

       "commit"

	 $driver->commit($dbh);

       Calls "$dbh->commit". Override if for some reason the DBI driver doesn't do it right.

       "rollback"

	 $driver->rollback($dbh);

       Calls "$dbh->rollback". Override if for some reason the DBI driver doesn't do it right.

       "savepoint"

	 $driver->savepoint($dbh, $name);

       A no-op. Override if your database does in fact support savepoints. The driver subclass should create a savepoint with the given $name. See
       the implementations in DBIx::Connector::Driver::Pg and DBIx::Connector::Driver::Oracle for examples.

       "release"

	 $driver->release($dbh, $name);

       A no-op. Override if your database does in fact support savepoints. The driver subclass should release the savepoint with the given $name.
       See the implementations in DBIx::Connector::Driver::Pg and DBIx::Connector::Driver::Oracle for examples.

       "rollback_to"

	 $driver->rollback_to($dbh, $name);

       A no-op. Override if your database does in fact support savepoints. The driver subclass should rollback to the savepoint with the given
       $name. See the implementations in DBIx::Connector::Driver::Pg and DBIx::Connector::Driver::Oracle for examples.

Authors
       This module was written and is maintained by:

       David E. Wheeler <david@kineticode.com>

       It is based on code written by:

       Matt S. Trout <mst@shadowcatsystems.co.uk>
       Peter Rabbitson <rabbit+dbic@rabbit.us>

Copyright and License
       Copyright (c) 2009-2010 David E. Wheeler. Some Rights Reserved.

       This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

perl v5.14.2							    2012-06-03					      DBIx::Connector::Driver(3pm)