Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl DBI help Connection refused !!!

Status
Not open for further replies.

mackiew

Programmer
Sep 15, 2000
18
0
0
UY
I have this problem:
The next message appears when I try to make an INSERT into a table:


Connection refused
DBD::pg::st execute failed: ERROR:
parser: parse error at or near "refused"


The situation is the next: I have a lot of processes making insertions
in the same database, and I suspect that is the cause of the message,
but I'm not sure.

Could be another cause?
How can I solve it?

I have tried the "autocommit" option on, and i still have the
problem.

Thank you.
 
ok...

1: What is in $DBI::errstr when the error occurs?

2: There's a RaiseError option when you initialise the DBI, are you using that?

Can you post a short script that demonstrates the problem as well please?

Mike
michael.j.lacey@ntlworld.com
 
Hi !

1: $DBI::errstr is null

2. Yes

I do can make inserts before this one. in fact, a lot of processes
that are copies of this one, (created with "forks") are making
insertions successfully.

The problematic code is as follows:


if (defined @pointerToARegistros) {
foreach $pointerRegistro (@pointerToARegistros) {
if (defined $pointerRegistro) {

my $sth = $dbh->prepare("insert into TNS values (
?,
?,
?,
?,
?,
?
)");

$sth->execute(
$pointerRegistro->{zona},
$pointerRegistro->{nombre_servidor},
$pointerRegistro->{orden},
$pointerRegistro->{transferencia},
$pointerRegistro->{nro_serie},
$pointerRegistro->{causa_inactividad}) ;
}
}
}


------------

thank you so much...
 
Hi Mac,

Could I suggest the following (you may be doing exactly this in your real program -- so please don't think I'm being funny)
[tt]
$InsStatement = 'insert into TNS values (?,?,?,?,?,?)';

my $sth = $dbh->prepare($InsStatement)
or die "Problem preparing insert statement\n$DBI::errstr\n";

$sth->execute(
$pointerRegistro->{zona},
$pointerRegistro->{nombre_servidor},
$pointerRegistro->{orden},
$pointerRegistro->{transferencia},
$pointerRegistro->{nro_serie},
$pointerRegistro->{causa_inactividad}
)or die "Problem executing insert statement\n$DBI::errstr\n";
[/tt]

Having said all of that -- if the same code is inserting records happilly in other instances of the script it seems that the problem may be in one of three areas:

1: Data dependant -- something funny about the data that causes the insert statement to fail. Embedded quotes or something?

2: Database contention -- failing because too may processes are trying to insert at once and MySQL's locking mechanism is getting upset

3: Number of connections to the database: "Connection refused" it says. Is there a limit on the number of cincurrent connections to a MySQL DB?

Mike
michael.j.lacey@ntlworld.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top