Hi, All:
     I have the almost same problems and I tried to initiate the database
connection in the child. But every time I can only make database connection and
do something only once. If I want to do it again it always shows me the
application error and my server is killed(the program exit). If I re-start the
server then it can make the database connection again but no more. The following
is my code:


 while ($new_sock = $main_sock->accept()) {
    $pid = fork();
    die "Cannot fork: $!" unless defined($pid);
    if ($pid == 0) {
       while (defined ($buf = <$new_sock>)) {
              if ($buf eq 'gettableinfo') {
                    gettableinfo();
                 }
              elsif ($buf eq 'Analysis') {{
                  Analysis();
               }
            }
         exit(0);
      }
   }
close ($main_sock);

sub gettableinfo() {
            my   $dsn = "dbi:ODBC:mysource";
             my $proxy = "hostname=path124-161b4;port=3333";
              my $dbh = DBI->connect("dbi:Proxy:$proxy;dsn=$dsn", '', '');
     # do something for this database handler
......................
    }

sub Analysis() {
         my   $dsn = "dbi:ODBC:mysource";
             my $proxy = "hostname=path124-161b4;port=3333";
              my $dbh = DBI->connect("dbi:Proxy:$proxy;dsn=$dsn", '', '');
     # do something for this database handler
     ....................................
    }
Every time I disconnect the database handler but still doesn't work more than
twice. Any help will be appreciated!!!!!



Qing


Reply via email to