perl -le 'use strict; use warnings; use DBI; my $h = DBI->connect("dbi:mysql:database=test", "xxx","yyy", {RaiseError => 0, PrintError => 0}) or die $DBI::errstr; my $s = $h->prepare(q/select * from does_not_exist/) or die "prepare: " . $DBI::errstr; $s->execute or print "\nexecute DBI:" . $DBI::errstr . " sth:", $s->errstr . " dbh:", $h->errstr; $h->do(q/rubbish/) or print $s->errstr, "\n"; execute DBI:Table 'test.does_not_exist' doesn't exist sth:Table 'test.does_not_exist' doesn't exist dbh:Table 'test.does_not_exist' doesn't exist You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rubbish' at line 1