<div>Thank u veymuch for your useful help.</div>
<div>It did work well now.Thank u again.: )</div>
<div> </div>
<div>I rechecked my codes to see whether i have other mistakes.</div>
<div>I find that featureReader.close() is used for the close of select operation.</div>
<div>For featService.UpdateFeatures operation,we should set the 3rd parameter to false like this:</div>
<div>featService.UpdateFeatures(resId, commands, false);</div>
<div>so the connections created by Update operation can be released.</div>
<div> <br>Jacky.<br><br> </div>
<div><span class="gmail_quote">2008/8/6, Zac Spitzer <<a href="mailto:zac.spitzer@gmail.com">zac.spitzer@gmail.com</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">try using featureReader close()<br><br>z<br><br>On Wed, Aug 6, 2008 at 7:30 PM, ÐìÕð <<a href="mailto:xuzhengeology@gmail.com">xuzhengeology@gmail.com</a>> wrote:<br>
> Hi,<br>> I use JSP and MySQL to develop .FDO connects these two parts together.<br>> In the software,i use resource service and feature service to search<br>> data stored in the MySQL database.Once i run the page for searching.<br>
> I will got two sleep process in MySQL.I guess the reason is i forgot to<br>> close connections.So i go back to the code to close connections and<br>> services.No use.<br>><br>> Codes here:<br>><br>> public Vector select(String mapName,String layerName,String<br>
> layerClassName,String filterString) throws MgException<br>> {<br>> MgResourceService resService =<br>> (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService);<br>> MgFeatureService featService =<br>
> (MgFeatureService)siteConnection.CreateService(MgServiceType.FeatureService);<br>><br>> MgMap map = new MgMap();<br>> map.Open(resService, mapName);<br>><br>> MgLayer layer = getLayerByName(map, layerName);<br>
><br>> MgFeatureQueryOptions query = new MgFeatureQueryOptions();<br>><br>> query.SetFilter(filterString);<br>> MgResourceIdentifier resId = new<br>> MgResourceIdentifier(layer.GetFeatureSourceId());<br>
> MgFeatureReader featureReader =featService.SelectFeatures(resId,<br>> layerClassName, query);<br>> Vector vec=new Vector();<br>> while (featureReader.ReadNext())<br>> {<br>><br>> MgAgfReaderWriter geometryReaderWriter = new MgAgfReaderWriter();<br>
> String mc = featureReader.GetString("MC");<br>> long id=featureReader.GetInt64("FeatId");<br>> long id1=featureReader.GetInt64("id");<br>> MgByteReader byteReader = featureReader.GetGeometry("GEOMETRY");<br>
><br>> MgGeometry geometry = geometryReaderWriter.Read(byteReader);<br>> MgPoint point = geometry.GetCentroid();<br>> double x = point.GetCoordinate().GetX();<br>> double y = point.GetCoordinate().GetY();<br>
> xy n=new xy(x,y,id,id1,mc);<br>> vec.add(n);<br>> geometryReaderWriter.delete(); //close<br>> }<br>><br>> resService.delete(); //close<br>> featService.delete(); //close<br>
> map.delete(); //close<br>> return vec;<br>><br>> }<br>><br>> out of this function,i closed the connection to the site with<br>> "siteConnection.delete();"<br>
><br>> Once i run this function ,checking the process of MySQL with "show<br>> processlist" in MySQL command shell,i will got two more sleep process,which<br>> can not be closed.<br>><br>> original:<br>
><br>> mysql> show processlist;<br>><br>> | Id | User | Host | db | Command | Time | State<br>> | Info<br>> | 1 | root | localhost:4955 | psd | Sleep | 2<br>
> | | NULL<br>> | 193 | root | localhost:3941 | NULL | Query | 0 | NULL |<br>> show processlist |<br>> | 194 | root | localhost:3963 | jsof_data | Sleep |<br>> 4 | | NULL<br>
> | 195 | root | localhost:3964 | jsof_data | Sleep | 8<br>> | | NULL<br>><br>> 2 rows in set (0.00 sec)<br>><br>> ofter used the function:<br>><br>> mysql> show processlist;<br>
><br>> | Id | User | Host | db | Command | Time | State<br>> | Info<br>> | 1 | root | localhost:4955 | psd | Sleep | 2<br>> | | NULL<br>> | 193 | root | localhost:3941 | NULL | Query | 0 | NULL |<br>
> show processlist |<br>> | 194 | root | localhost:3963 | jsof_data | Sleep |<br>> 4 | | NULL<br>> | 195 | root | localhost:3964 | jsof_data | Sleep | 8<br>> | | NULL<br>
> | 196 | root | localhost:3965 | jsof_data | Sleep<br>> | 2 | | NULL<br>> | 197 | root | localhost:3966 | jsof_data | Sleep | 3<br>> | | NULL<br>><br>><br>><br>
> 6 rows in set (0.00 sec)<br>><br>> i tried to kill the sleep process with the ways as follow:<br>><br>> <%@ page language="java" import="java.util.*" pageEncoding="gb2312"%><br>
> <%@ page import="java.sql.*"%><br>> <%@ page import="java.util.*"%><br>> <%@ page import="java.io.*"%><br>><br>> <%<br>> String path = request.getContextPath();<br>
> String basePath = request.getScheme() + "://"<br>> + request.getServerName() + ":" +<br>> request.getServerPort()<br>> + path + "/";<br>
> Class.forName("com.mysql.jdbc.Driver");<br>> String url =<br>> "jdbc:mysql://localhost/psd?characterEncoding=utf8&user=root&password=root";<br>> Connection conn = DriverManager.getConnection(url);<br>
> Statement stmt = conn.createStatement();<br>> Statement stmt2 = conn.createStatement();<br>> ResultSet rs = stmt.executeQuery("show processlist");<br>> while (rs.next()) {<br>> String Id = rs.getString("Id");<br>
> String cmd = rs.getString("Command");<br>> String Time = rs.getString("Time");<br>> int i = Integer.parseInt(Time);<br>> if(i>10&&cmd.equals("Sleep")) //Kill the<br>
> process which has been slept for more than 10 seconds<br>> stmt2.executeQuery("kill "+Id);<br>> else<br>> }<br>> rs.close();<br>> stmt.close();<br>
> stmt2.close();<br>> conn.close();<br>> %><br>><br>> But i will get "The MySQL has gone away"error message.I have to restart<br>> MapGuideServer service to fix this problem.<br>><br>
> Can anyhelp me on this problem?<br>><br>> Thanks for your attention:)<br>><br>> Jacky.<br>><br>> _______________________________________________<br>> mapguide-users mailing list<br>> <a href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a><br>><br>><br><br><br><br>--<br>Zac Spitzer -<br><a href="http://zacster.blogspot.com">http://zacster.blogspot.com</a> (My Blog)<br>
+61 405 847 168<br>_______________________________________________<br>mapguide-users mailing list<br><a href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a><br>
</blockquote></div><br>