DBD-DtfSQLmac

 view release on metacpan or  search on metacpan

samples/dbi_3_connect.pl  view on Meta::CPAN

 
eval { 
	my $dbh2 = DBI->connect($dsn, 'user', 'password', {AutoCommit => 0}) || die ;	
};


print "\n\nDisconnecting connection 1 ... ";
$dbh1->disconnect;
print "ok.\n\n";

print "Sent a ping to connection 1 to see if the connection is alive (this should fail).\n\n";
my $alive = $dbh1->ping();
print "ping ...";
($alive) ? print " still alive.\n\n" : print " connection dead.\n\n";


print "Try a second connection after the first has been closed (this should work) ... ";
my $dbh3 = DBI->connect(	$dsn, 
							'dtfadm', 
							'dtfadm', 
							{RaiseError => 1, AutoCommit => 0}
					   ) ||  die "Can't connect to database: " . DBI->errstr;
print "ok.\n\n";

print "Sent a ping to the second connection to see if connection is alive (this should work).\n\n";
$alive = $dbh3->ping();
print "ping ...";
($alive) ? print " still alive.\n\n" : print " connection dead.\n\n";

print "\nDisconnecting ... ";
$dbh3->disconnect;
print "ok.\n\n";

1;


t/20connect.t  view on Meta::CPAN

#! perl -w
#
#
#   This test connects and disconnects to the test database, checks
#   if the connection is alive or not and checks if we can connect a 
#   second time and as an unknown user.
#

$^W = 1;

#
#   Make -w happy
#
$test_dsn = '';
$test_user = '';

t/20connect.t  view on Meta::CPAN

    #
    #   Disconnect from first connection
    #

	#
	### Test 3
    Test($state or $dbh->disconnect())
	  or DbiError($dbh->err, $dbh->errstr);
	  
	#
    # Check if the first connection is alive (this should fail)  
    #

	#
	### Test 4
    Test($state or (! $dbh->ping() ) )
	  or DbiError($dbh->err, $dbh->errstr);


    #
    #   Try a second connection with an unknown user and password, this should fail

t/20connect.t  view on Meta::CPAN

	#
	
	#
	### Test 6
    undef $dbh;
    Test($state or $dbh = DBI->connect($test_dsn, $test_user, $test_password) )
	or die "Sorry, cannot connect: ", $DBI::errstr, "\n";

   
   	#
    # Check if this connection is alive (this should work)  
    #

	#
	### Test 7
    Test($state or $dbh->ping() )
	  or DbiError($dbh->err, $dbh->errstr);
   
   
    #
    #   Finally disconnect.

t/README.tests  view on Meta::CPAN

  00load.t				Tests loading of required modules and driver.
  
  01base.t	    		This is essentially the base.t from DBD::Oracle. It
						checks whether the driver may be installed.

  10dsn_driverlist.t   	This test lists all available DBI drivers, checks if 
  						the DtfSQLmac driver is found and lists all available 
						data sources for our driver.

  20connect.t   		This test connects and disconnects to the test database, 
  						checks if the connection is alive or not and checks if we 
						can connect a second time and as an unknown user.

  30createdrop.t   		Creates a table and drops it.

  40insertfetch.t  		Inserts a row into a table and retrieves it.

  50bindparam.t    		Checks the bind_col() method and the internal function 
  						dbd_ph_bind().
						
  51listfields.t   		Checks the attributes of a statement handle, currently



( run in 0.631 second using v1.01-cache-2.11-cpan-39bf76dae61 )