On Mon, 2007-09-03 at 17:26 +0800, Ow Mun Heng wrote:
> Just wondering how to if there's a way to determine the script I"m
> writing is preserving the same connection string to the server.
> 
> I'm hitting the SQL Server to query from 5 tables (hence 5 different
> sessions running under screen) at intervals of 30 mins. Is connect_cache
> any use here under these intervals or I'm better off just using connect?

BTW, I found a script on the net to check some kind of connect status,
but seems like it provides the same results. (I guess I'm using this
script wrongly)


#!/usr/bin/perl
use strict;

use DBI;
my $dbh = DBI->connect_cached('dbi:Pg:dbname=hmxmms', 'user', 'pass',
{RaiseError => 1, AutoCommit => 0 });

print "Pg $dbh:  & AutoCommit Stat :$dbh->{AutoCommit}\n";
$dbh = DBI->connect_cached('dbi:Pg:dbname=hmxmms', 'user', 'pass',
{RaiseError => 1, AutoCommit => 0});
print "Pg $dbh:  & AutoCommit Stat :$dbh->{AutoCommit}\n";

my $dbh2 =
DBI->connect_cached("DBI:Sybase:host=xxx.xxx.xxx;port=1137,database=YYYY", 
'macrow', 'macrow123',
{RaiseError => 1, PrintError => 0});
print "SQL $dbh:  & AutoCommit Stat :$dbh->{AutoCommit}\n";

my $dbh2 =
DBI->connect_cached("DBI:Sybase:host=xxx.xxx.xxx;port=1137,database=YYYY", 
'username', '123',
{RaiseError => 1, PrintError => 0});
print "SQL $dbh:  & AutoCommit Stat :$dbh->{AutoCommit}\n";


my $dbh2 =
DBI->connect("DBI:Sybase:host=xxx.xxx.xxx;port=1137,database=YYYY",
'username', '123',
{RaiseError => 1, PrintError => 0});
print "SQL $dbh:  & AutoCommit Stat :$dbh->{AutoCommit}\n";

my $dbh2 =
DBI->connect("DBI:Sybase:host=xxx.xxx.xxx;port=1137,database=YYY",
'username', '123',
{RaiseError => 1, PrintError => 0});
print "SQL $dbh:  & AutoCommit Stat :$dbh->{AutoCommit}\n";


Results
========
Pg  DBI::db=HASH(0x82d2b3c):  & AutoCommit Stat :
Pg  DBI::db=HASH(0x82d2b3c):  & AutoCommit Stat :
SQL DBI::db=HASH(0x82d2b3c):  & AutoCommit Stat :
SQL DBI::db=HASH(0x82d2b3c):  & AutoCommit Stat :
SQL DBI::db=HASH(0x82d2b3c):  & AutoCommit Stat :
SQL DBI::db=HASH(0x82d2b3c):  & AutoCommit Stat :

Reply via email to