From: Herve C. <her...@it...> - 2004-10-12 07:36:43
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Hello again,<br> For sure, my question is stupid but ....<br> I' ve got an function that construct a layer from a database : <br> <br> <i> /**<br> *this function create an layer given an MySQL Table and a style.<br> *If an error occurs, return null<br> **/<br> public DefaultMapLayer makeLayer(String tableName,Style style){<br> //setting up params<br> java.util.Map params = new HashMap();<br> params.put("dbtype", "mysql");<br> params.put("host", "localhost"); //the name or ip address of the machine running MySQL<br> params.put("port","3306"); //the port that PostGIS is running on (generally 3306)<br> params.put("database", "mydb");//the name of the database to connect to.<br> params.put("user", "theuser"); //the user to connect with<br> params.put("passwd", "thepassword"); //the user's password.<br> <br> try{<br> DataStore mySQLpgDatastore = DataStoreFinder.getDataStore(params);<br> FeatureSource fs = mySQLpgDatastore.getFeatureSource(tableName);<br> return(new DefaultMapLayer(fs, style));<br> }<br> catch(Exception e){<br> System.err.println(e.getMessage());<br> return null;<br> }<br> }<br> </i><br> This function work fine, but I need also to make a layer from a SQL Query. <br> The query would be something like <br> <br> <i>SELECT House.id, House.geom, House.name FROM House, Town<br> Where Town.name="LakeCity"<br> AND House.town = town.id<br> </i><br> Is it possible to do this ?<br> I'd try innocently to replace in my function <i>tableName</i> with an sql query, but it didn't work :-)<br> <br> Herve Cros wrote: <blockquote cite="mid...@it..." type="cite"> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> Thanks a lot !!!!<br> you are right, now it work fine. <br> <br> Thanks you <br> <br> Philippe Suray wrote: <blockquote cite="mid008601c4aab9$59949d40$a60...@ma..." type="cite"> <meta http-equiv="Content-Type" content="text/html; "> <meta content="MSHTML 6.00.2800.1126" name="GENERATOR"> <div><font color="#0000ff" face="Arial" size="2"><span class="673225508-05102004">Hello,</span></font></div> <div><font color="#0000ff" face="Arial" size="2"><span class="673225508-05102004"></span></font> </div> <div><font color="#0000ff" face="Arial" size="2"><span class="673225508-05102004">I think you must have <font color="#000000" face="Times New Roman" size="3">params.put("port", "3306"); </font></span></font><font><span class="673225508-05102004">In source file, param 'port' is declared like String.class</span></font></div> <div><font><span class="673225508-05102004"></span></font> </div> <div><font color="#0000ff" face="Arial" size="2"><span class="673225508-05102004">regards</span></font></div> <div><font color="#0000ff" face="Arial" size="2"><span class="673225508-05102004"></span></font> </div> <div><font color="#0000ff" face="Arial" size="2"><span class="673225508-05102004">Suray Philippe</span></font></div> <div><font color="#0000ff" face="Arial" size="2"><span class="673225508-05102004"></span></font> </div> <blockquote> <div class="OutlookMessageHeader" align="left" dir="ltr"><font face="Tahoma" size="2">-----Message d'origine-----<br> <b>De :</b> <a class="moz-txt-link-abbreviated" href="mailto:geo...@li...">geo...@li...</a> [<a class="moz-txt-link-freetext" href="mailto:geo...@li...">mailto:geo...@li...</a>]<b>De la part de</b> Herve Cros<br> <b>Envoyé :</b> mardi 5 octobre 2004 10:43<br> <b>À :</b> <a class="moz-txt-link-abbreviated" href="mailto:geo...@li...">geo...@li...</a><br> <b>Objet :</b> Re: [Geotools-gt2-users] how to mysql + shapefile<br> <br> </font></div> I would like, as martin, to use mySQL DataStore. <br> I had follow Rueben schulz advice so I read and try to adapt the How+to+use+a+PostGISDataStore but I did not succed ...<br> <span class="java-quote"><br> the code I have is <br> <br> java.util.Map params = new HashMap();<br> params.put("dbtype", "mysql"); //I had also try with "postgis"<br> params.put("host", "localhost"); <br> params.put("port", new Integer(3306)); <br> params.put("database", "test"); //the name of the database to connect to.<br> params.put("user", "testuser"); //the user to connect with<br> params.put("passwd", ""); //no password for this user<br> <br> DataStore mySQLpgDatastore = DataStoreFinder.getDataStore(params);<br> FeatureSource fsBC = mySQLpgDatastore.getFeatureSource("bc");<br> int nb = fsBC.getCount(Query.ALL);<br> System.out.println("bc count: " + nb);<br> <br> <br> the program halt on the folowing line :</span><br> <span class="java-quote"></span><br> <span class="java-quote"> FeatureSource fsBC = pgDatastore.getFeatureSource("</span>bc<span class="java-quote">"); </span><br> <span class="java-quote"></span><br> <span class="java-quote">where bc is the name of a table of my database</span><br> <span class="java-quote">the table bc contain one Geometry column, did this column should have a particular name ?</span><br> <span class="java-quote">did the table should contain other information (like an feature identifier) ?<br> may I have other column wich are not user by the GIS without interfering ?<br> did I had to respect a particular order in table colubm to make it work ?<br> </span><span class="java-quote">... </span><br> please, any one can help me ?<br> <span class="java-quote"><br> </span><br> <br> <br> Rueben Schulz wrote: <blockquote cite="mid1095996817.14580.4.camel@localhost.localdomain" type="cite"> <pre wrap="">Hi, Take a look at: <a class="moz-txt-link-freetext" href="http://docs.codehaus.org/display/GEOTOOLS/How+to+use+a+PostGISDataStore">http://docs.codehaus.org/display/GEOTOOLS/How+to+use+a+PostGISDataStore</a> This does not cover mysql, but the same technique can be used. Unfortunately the parameters needed by mysql are not yet described at: <a class="moz-txt-link-freetext" href="http://docs.codehaus.org/display/GEOTOOLS/DataStoreFinder+Parameters">http://docs.codehaus.org/display/GEOTOOLS/DataStoreFinder+Parameters</a> so you will need to hunt for them in the mysqlDataStore code. Rueben P.S. Once you find the parameters, please place them on the DataSterFinder parameters wiki page (if you have time). On Wed, 2004-09-22 at 08:19, Pizza Al Tonno wrote: </pre> <blockquote type="cite"> <pre wrap="">Hi, I am pretty new to this stuff and i have created successfully my first shapfile maps. Now i would like to switch to a MySQL DB DataStore, but i really do not know how to start. Can anyone help me, or give me some good advice, link to visit?? Thanks Martin _______________________________ Do you Yahoo!? Declare Yourself - Register online to vote today! <a class="moz-txt-link-freetext" href="http://vote.yahoo.com">http://vote.yahoo.com</a> ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: <a class="moz-txt-link-freetext" href="http://sf.net/ppc_contest.php">http://sf.net/ppc_contest.php</a> _______________________________________________ Geotools-gt2-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Geo...@li...">Geo...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users">https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users</a> </pre> </blockquote> <pre wrap=""><!----> ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: <a class="moz-txt-link-freetext" href="http://sf.net/ppc_contest.php">http://sf.net/ppc_contest.php</a> _______________________________________________ Geotools-gt2-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Geo...@li...">Geo...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users">https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users</a> </pre> </blockquote> <br> ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more <a class="moz-txt-link-freetext" href="http://productguide.itmanagersjournal.com/guidepromo.tmpl">http://productguide.itmanagersjournal.com/guidepromo.tmpl</a> _______________________________________________ Geotools-gt2-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Geo...@li...">Geo...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users">https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users</a> </blockquote> </blockquote> <br> ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more <a class="moz-txt-link-freetext" href="http://productguide.itmanagersjournal.com/guidepromo.tmpl">http://productguide.itmanagersjournal.com/guidepromo.tmpl</a> _______________________________________________ Geotools-gt2-users mailing list <a class="moz-txt-link-abbreviated" href="mailto:Geo...@li...">Geo...@li...</a> <a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users">https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users</a> </blockquote> <br> </body> </html> |