Stephen Toney has asked for the wisdom of the Perl Monks concerning the following question:

Hi everyone,

Using MyODBC with MySQL 5.0 hangs after delivering the data from the database. Here's a tiny program the shows the problem.
#! /usr/local/bin/perl -w use strict; use CGI qw(:standard escapeHTML); $::DSN = "MWEBMYSQL"; use DBI; $::dbh = DBI->connect ("dbi:ODBC:$::DSN", "ODBC") || die ("Ca +nnot connect to Data Source '$::DSN'"); my ($count) = $::dbh->selectrow_array ("select count(*) from logon"); print header ('text/html', '200 OK'); print "<html><body>Found $count records in LOGON</body></html>";
This works with SQL Server and Foxpro db's using ODBC, but with MySQL there is no response until the server times out. When I run it from the command line the correct results are shown, but the cursor stays right after </html> and there is no command prompt until the server times out. Since the correct results are shown, I know it's not a connection problem. So what could it be?

MySQL works correctly from mysql.exe and also when I issue ODBC queries from another language. Just not with Perl.

"marto" suggested (thanks!) that I should use DBD::MySQL. However, the latest on the ActiveState website is version 2.1004, November 16, 2001. Has anyone tried this with MySQL 5.0 yet?

Thanks a million for any ideas!

Stephen

Replies are listed 'Best First'.
Re: MySQL ODBC hangs
by marto (Cardinal) on Nov 18, 2005 at 12:17 UTC
      Thanks, I just grabbed it from theoryx5. Somehow I thought ActiveState would always be the most up-to-date. Silly me!
A reply falls below the community's threshold of quality. You may see it by logging in.