[mapguide-internals] Cannot create any more connections to the OSGeo.MySQL FDO provider

Julius Gelšvartas julius at infoera.lt
Wed Oct 10 02:47:32 EDT 2007


Hello

 

I have an application which is continuously storing data to MySql using
mapguide featureservice.

I am using MGOS 1.2.

 

The connection is sometimes established one after another without pauses but
I think I am

closing connections correctly and I get the following

error:

 

Cannot create any more connections to the OSGeo.MySQL FDO provider.

Exception occurred in method MgFdoConnectionManager.Open at line 256 in file
c:\build_bond_area\mapguide_open_source_v1.2\build_18.1\mgdev\server\src\com
mon\manager\FdoConnectionManager.cpp

 

Then after some tine it again starts to work.

Any help would be very appreciated. Thanks in advance.

 

Julius

 

Here is the code:

        public bool Store(CMsg_Event_GC072 Msg, bool report)

        {

            try

            {

                MapGuideApi.MgInitializeWebTier(path + "webconfig.ini");

                MgUserInformation userInfo = new
MgUserInformation("Administrator", plainText);

                MgSiteConnection site = new MgSiteConnection();

                site.Open(userInfo);

 

                MgFeatureService featureService =
site.CreateService(MgServiceType.FeatureService) as MgFeatureService;

                MgResourceIdentifier fdo = new
MgResourceIdentifier("Library://Lietuva/Connections/Cars.FeatureSource");

 

                MgPropertyCollection properties = new
MgPropertyCollection();

                properties.Add(new MgInt32Property("CarId", Msg.Id));

                properties.Add(new MgBooleanProperty("KeyOnOff",
Msg.OnOff));

                properties.Add(new MgDoubleProperty("Tacho", Msg.Tacho));

                properties.Add(new MgInt32Property("RTime", Msg.Time));

                MgInsertFeatures insertFeatures;

                MgDeleteFeatures deleteFeatures;

                MgFeatureCommandCollection featCmdCollection = new
MgFeatureCommandCollection();

                if (report == false)

                {

                    insertFeatures = new
MgInsertFeatures("CarEventsCurrent", properties);

                    featCmdCollection.Add(insertFeatures);

                }

                else

                {

                    MgFeatureQueryOptions query = new
MgFeatureQueryOptions();

                    String querystr = "CarId = '" + Msg.Id + "'";

                    query.SetFilter(querystr);

 

                    MgFeatureReader reader =
featureService.SelectFeatures(fdo, "LastAddedEvent", query);

 

                    if (reader.ReadNext())

                    {

                        int time = reader.GetInt32("RTime");

                        reader.Close();

                        if (Msg.Time <= time)

                        {

                            querystr = "CarId = '" + Msg.Id + "'";

                            query.SetFilter(querystr);

                            MgFeatureReader featureReader =
featureService.SelectFeatures(fdo, "CarEventsCurrent", query);

                            int t = 0;

                            while (featureReader.ReadNext())

                            {

                                t++;

                            }

                            featureReader.Close();

                            if (t != 1)

                            {

                                querystr = "CarId = '" + Msg.Id + "' AND
RTime <= '" + Msg.Time + "'";

                                deleteFeatures = new
MgDeleteFeatures("CarEventsCurrent", querystr);

                                featCmdCollection.Add(deleteFeatures);

                            }

                        }

                        else

                        {

                            MgPropertyCollection prop = new
MgPropertyCollection();

                            prop.Add(new MgInt32Property("RTime",
Msg.Time));

                            querystr = "CarId = '" + Msg.Id + "'";

                            MgUpdateFeatures updateFeatures = new
MgUpdateFeatures("LastAddedEvent", prop, querystr);

                            featCmdCollection.Add(updateFeatures);

                            insertFeatures = new
MgInsertFeatures("CarEvents", properties);

                            featCmdCollection.Add(insertFeatures);

                            querystr = "CarId = '" + Msg.Id + "'";

                            query.SetFilter(querystr);

                            MgFeatureReader featureReader =
featureService.SelectFeatures(fdo, "CarEventsCurrent", query);

                            int t = 0;

                            while (featureReader.ReadNext())

                            {

                                t++;

                            }

                            featureReader.Close();

                            if (t != 1)

                            {

                                querystr = "CarId = '" + Msg.Id + "' AND
RTime <= '" + Msg.Time + "'";

                                deleteFeatures = new
MgDeleteFeatures("CarEventsCurrent", querystr);

                                featCmdCollection.Add(deleteFeatures);

                            }

                        }

                    }

                    else

                    {

                        reader.Close();

                        MgPropertyCollection prop = new
MgPropertyCollection();

                        prop.Add(new MgInt32Property("CarId", Msg.Id));

                        prop.Add(new MgInt32Property("RTime", Msg.Time));

                        insertFeatures = new
MgInsertFeatures("LastAddedEvent", prop);

                        featCmdCollection.Add(insertFeatures);

                        insertFeatures = new MgInsertFeatures("CarEvents",
properties);

                        featCmdCollection.Add(insertFeatures);

                        querystr = "CarId = '" + Msg.Id + "'";

                        query.SetFilter(querystr);

                        MgFeatureReader featureReader =
featureService.SelectFeatures(fdo, "CarEventsCurrent", query);

                        int t = 0;

                        while (featureReader.ReadNext())

                        {

                            t++;

                        }

                        featureReader.Close();

                        if (t != 1)

                        {

                            querystr = "CarId = '" + Msg.Id + "' AND RTime
<= '" + Msg.Time + "'";

                            deleteFeatures = new
MgDeleteFeatures("CarEventsCurrent", querystr);

                            featCmdCollection.Add(deleteFeatures);

                        }

                    }

                }

                if (featCmdCollection.Count > 0)

                {

                    featureService.UpdateFeatures(fdo, featCmdCollection,
false);

                }

                return true;

            }

            catch (MgApplicationException ex)

            {

                Log(ex.GetDetails());

                return false;

            }

            catch (MgFdoException ex)

            {

                Log(ex.GetDetails());

                return false;

            }

            catch (MgInvalidArgumentException ex)

            {

                Log(ex.GetDetails());

                return false;

            }

            catch (MgUnclassifiedException ex)

            {

                Log(ex.GetDetails());

                return false;

            }

        }



More information about the mapguide-internals mailing list