#!/usr/bin/perl use DBI; $db_name='zjzc'; $ip='127.0.0.1'; $user="root"; $passwd="1234567"; $dbh=""; $dbh = DBI->connect("dbi:mysql:database=$db_name;host=$ip;port=3306",$user,$passwd,{ RaiseError => 1, AutoCommit => 0 }) or die "can't connect to database ". DBI-errstr; eval{ $dbh->do("insert into test values('$ARGV[0]')") ; sleep (100); $dbh->commit();}; if( $@ ) { #warn "Database error: $DBI::errstr "; $dbh->rollback(); #just die if rollback is failing }; $dbh->disconnect; slave:/root/check#