I think we may need to see a little more code to figure out what is going on here. My guess however, is that you are either calling exit without performing $dbh->disconnect or alternatively calling $dbh->disconnect without performing a $sth->finish - Such code order can result in warnings similar to what you describe.