简体   繁体   中英

Why can't I disconnect my database handles with DBD::DB2?

My perl script is slow but works. I am considering throwing it out and building a true DB2 application with proper binds and such; however, in the meantime I want this to work as a place holder.

I looked at this documentation and it mentions:

$dbh->disconnect();

However I cannot use it because it throws this error.

Can't locate object method "disconnect" via package "dbh" (perhaps load "dbh"?) at ./ProgramTree.pl line 119.

I know my temporary application is leaking and growing because it is recursively opening database handles. Am I missing something fundamental?

That error sounds an awful lot like the sigil is missing and you're running just dbh->disconnect(); .


Look at what happens when an object doesn't have a method:

[~] perl -e'my $dbh = bless {}, q/foo/; $dbh->disconnect();'
    Can't locate object method "disconnect" via package "foo" at -e line 1.

Compared to when you're calling that method on the bareword "dbh":

[~] perl -e'dbh->disconnect();'
    Can't locate object method "disconnect" via package "dbh" (perhaps you forgot to load "dbh"?) at -e line 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM