From: "Malcolm J Harwood" <[EMAIL PROTECTED]> > [Tue Dec 28 21:07:34 2004] [error] DBD::mysql::db prepare failed: handle 2 > is owned by thread 265c564 not current thread 14ce78c (handles can't be > shared between threads and your driver may need a CLONE method added) at > f:/web/presa/modules/GetCategories.pm line 18.\n
This means you've got a db handle before the thread was cloned (created by the connect_on_init - which connects when the process, not the thread, is created). The handle can't be shared between the parent and child thread, generating the above error. > So I have commented out the following line in preload.pl: > ###Apache::DBI->connect_on_init("DBI:mysql:database=presa;host=localhost", > "ODBC", undef, {PrintError =>1, RaiseError=>0, AutoCommit => 1}); > > And in GetCategories.pm I have used only: > > use DBI; > my $dbh = ...; > > Well, in this case the script works, but I don't know if this way of using > DBI is the best way. If you are using multiple threads, then yes. (Though I'm not sure how Apache::DBI's thread pool works with multiple threads, presumably it provides seperate pools for each thread, but I could be wrong there). -- Ok, but I have seen an example in a tutorial where the database is accessed with the username, and the password from a startup.pl file exactly like this: Apache::DBI->connect_on_init("DBI:mysql:database=presa;host=localhost", "ODBC", undef, {PrintError =>1, RaiseError=>0, AutoCommit => 1}); In what situation can I access the database at the server startup? I would like to preload the DBI module at the server startup and to be able to create persistent connections in order to make them faster. Thank you. Teddy -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html