We are using MySQL. Does anyone know if $dbh->ping is implemented for
MySQL?

Thanks,
-Kevin

[EMAIL PROTECTED] wrote:
> 

The connect/disconnect question depends to some extent on your particular
database and how long it takes it to set up a connection.  From what
I've heard,
MySQL has very fast connection times, while Oracle has slow connection
times,
just to throw out a couple of likely extremes.  I'd be inclined to
leave the
connection open.

You might want to test the database connection each time with
$dbh->ping, or by
sending it a simple query like "SELECT 1" which will be fast if the
connection
is up, but should fail if the connection is down.  I wouldn't assume the
connection was down because your main INSERT statement failed; there
are lots of
other reasons an INSERT might fail.




[EMAIL PROTECTED] on 08/23/2001 03:24:16 PM

To:   Henrik Tougaard 
cc:   [EMAIL PROTECTED] (bcc: Wesley
      Sheldahl/Lex/Lexmark)
Subject:  Re: RE: Error messages and such



Thanks for the reply. Now for another question.

I have an application that runs in the background and periodically
(every 10 seconds) needs to pull records from one database and insert
them into another database. What's the best way (efficiency wise) to
do this? Would it be best to open a connection to each database and
just use the handles throughout the life of the application, or should
I connect and disconnect every 10 seconds to each database? Also, if I
leave the connections open, then how do I tell if the database and/or
network goes down? Is it safe to assume that if the call to execeute
fails that there's something wrong with the database, at which point I
will need to try to re-connect?

Thanks,
-Kevin

Henrik Tougaard  wrote:
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>
> I have two questions. First, where can I find the possible error
> strings that $DBI::errstr might contain?

You will have to look in (at least) three places:
  1) the DBI documentation (and probably also the code) to see
     the error messages (if any) that the DBI can raise
  2) the documentation (and also the code) for the DBD driver
     that you use.
  3) The documentation (and preferably also the code, but that
     might be a tad more difficult to find) for the database
     system that you use.

There is no simple answer.

>
> Second, when a connection to a database is made via DBI->connect(..),
> how long will that connection stay open? Does it matter if the
> database is on the same machine or on a separate machine from the DBI
> application?
>
It will stay open until you $dbh->disconnect it (or something
terrible happens to either your programme or the database system :).
It doesn't matter if it is on the samme or another machine (or on
another planet for that matter).

Henrik






Reply via email to