On Thu, 2006-12-07 at 10:49 -0600, Prashanth Meka wrote: > I am trying to find a function that will create a persistent connection. > Does connect_cached provide a persistent connection? From the CLI/ODBC > traces, it looks like this program connects two separate times to the > database: > > $dbh1 = DBI->connect_cached("dbi:DB2:SAMPLE", "user", "pass"); > $dbh1->disconnect; > $dbh2 = DBI->connect_cached("dbi:DB2:SAMPLE", "user", "pass"); > $dbh2->disconnect; > > How exactly does connect_cached function?
The connect_cached() function stores a copy of the database handle, and, if called again with the same arguments, returns the cached version of the handle rather than creating a new one (and only if it determines that the cached handle is still valid). Your example above connected twice because you disconnected the first handle before trying to grab it again. It's unclear exactly what you mean by "persistent connection", but connect_cached is probably not the solution you are looking for. Connection caching is usually done at another level. For example, if this is a web-based application, you should look at Apache::DBI: http://search.cpan.org/~abh/Apache-DBI/DBI.pm -- Greg Sabino Mullane [EMAIL PROTECTED] End Point Corporation 610-983-9073
signature.asc
Description: This is a digitally signed message part