#!perl -w
# DBITest.pl
use strict;
use DBI;

my $driver = "mysql";
my $db_name = "test";
my $host = "localhost";
my $port = "3306";
my $username = "dbman";
my $password = "dbman";
my $query = "select * from dual";

print "let's start ;-) \n";
my $dbh = DBI->connect("DBI:$driver:database=$db_name;host=$host;port=$port", $username, $password) or die ("connection can not be established \n");
print "connection succesfully established \n";
my $sth = $dbh->prepare($query) or die ("statement could not be prepared");
print "statement successfully prepared\n";
$sth->execute or die ("statement could not be executed: $DBI::err ($DBI::errstr) \n");
print "statement successfully executed \n";
$sth->finish();
print "statement and connection closed \n" if $dbh->disconnect;
print "that's the end \n";