the following is solved by adding ` {InactiveDestroy => 1}` to the $dbh
On Sep 3, 2011, at 9:19 PM, Mr. Puneet Kishor wrote:
> I have the following code
>
> $layer_gmna->{name} = 'gmna';
> $layer_gmna->{status} = $mapscript::MS_ON;
> $layer_gmna->{type} = $mapscript::MS_LAYER_POLYGON;
> $layer_gmna->{connection} = "host=$dbhost port=$dbport dbname=$dbname
> user=$dbuser password=$dbpswd";
> $layer_gmna->setConnectionType($mapscript::MS_POSTGIS, '');
> $layer_gmna->{data} = 'the_geom FROM ..';
> $layer_gmna->{classitem} = 'interval_name';
>
> my $dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$dbhost;port=$dbport",
> $dbuser, $dbpswd);
>>>> my $sth = $dbh->prepare("SELECT interval_name, color_hex FROM
>>>> intervals_old");
> $sth->execute or debug $sth->errstr;
> while (my ($interval_name, $color_hex) = $sth->fetchrow_array) {
> my $classObj = new mapscript::classObj( $layer_gmna );
> $classObj->{name} = $interval_name;
> $classObj->setExpression( $interval_name );
> my $styleObj = styleObj(classObj => $classObj, colorObj =>
> colorObj('hex' => $color_hex));
> }
>
>
> By the time I reach the line marked with '>>>', the db connection is closed.
> I get the following message: "DBD::Pg::st execute failed: server closed the
> connection unexpectedly. This probably means the server terminated abnormally
> before or while processing the request. at
> /Users/punkish/Documents/www/geomaps/lib/geomaps.pm line 1225."
>
> Maybe MapServer has nothing to do with it, but, is it possible that MapServer
> efficiently closes all DB connections after it has pulled in the data from
> the tables? If so, is there a way I can stop it from doing so?
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users