perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Octavian Rasnita" <>
Subject Error: handles can't be shared between threads
Date Thu, 19 May 2005 17:47:53 GMT

I am using mod_perl 2.0.0 under Windows 2000, with perl 5.8.6, Apache
2.0.54, and Apache::DBI  version 0.96.

I want to create a module that uses for connecting to the MySQL
database, then using that module in all other modules that might need a

Here is the module I have tried:

package Site::MySQL;

use strict;
use DBI ();

sub dbh {
return DBI->connect("DBI:mysql:database=test;host=localhost", "root", undef,
{RaiseError => 0, PrintError => 1, AutoCommit => 1});

I get the $dbh in other modules using:
my $dbh = Site::MySQL::dbh();

If I run the programs in command line, they work fine, but if I run them
using mod_perl, it gives an error in the log file:

[Thu May 19 20:36:01 2005] [error] DBD::mysql::db prepare failed: handle 2
is owned by thread 225321c not current thread 17cde94 (handles can't be
shared between threads and your driver may need a CLONE method added) at
e:/web/presa3/modules/Presa/ line 34.\n

I have tried to use and not to use Apache::DBI but with the same results.

I don't have any idea where could be the problem. Is the module that uses
DBI bad? Isn't a good idea to create a functional module instead of an OOP
Or... what can I try to make them work?

Thank you.


View raw message