Ok. I have converted a shapefile in a sql file with a tool named shp2mysql.
So i have imported this file in my mysql database and i have a table with a
geometry column. Now a have to write a java program that connecting to my
database open my table with geometry column in a map.

Thi is my code:
Map params = new HashMap();
                        params.put( "database", "Fabbricati" );
                        //params.put( "dbtype", "mysql");
                        params.put( "dbtype", "postgis");
                        params.put( "host", "localhost");
                        //params.put( "port", "3306");
                        params.put( "port", new Integer(3306));
                        params.put( "user", "*****");
                        params.put( "passwd", "*******");
                        
                        MySQLDataStoreFactory factory = new 
MySQLDataStoreFactory();
                        //DataStore ds = (DataStore) 
factory.createDataStore(params);
                        FeatureSource fs = ds.getFeatureSource("prova");

                        //create the map 
                        MapContext map = new DefaultMapContext();
                        map.setTitle("ShapeFile Viewer");
                        map.addLayer(fs, null);
                        
                        // show the map
                        JMapFrame.showMap(map);

and this is my console output:
13-giu-2011 10.17.24 org.geotools.jdbc.JDBCFeatureSource buildFeatureType
AVVERTENZA: Error occured determing srid for prova.ogc_geom
com.mysql.jdbc.exceptions.jdbc4.MySQLDataException: '4.294967295E9' in
column '1' is outside valid range for the datatype INTEGER.
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at com.mysql.jdbc.Util.getInstance(Util.java:381)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1000)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
        at
com.mysql.jdbc.ResultSetImpl.throwRangeException(ResultSetImpl.java:7800)
        at 
com.mysql.jdbc.ResultSetImpl.parseIntAsDouble(ResultSetImpl.java:7055)
        at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2608)
        at
org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
        at
org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
        at
org.geotools.data.mysql.MySQLDialect.getGeometrySRID(MySQLDialect.java:200)
        at
org.geotools.data.mysql.MySQLDialectBasic.getGeometrySRID(MySQLDialectBasic.java:74)
        at
org.geotools.jdbc.JDBCFeatureSource.buildFeatureType(JDBCFeatureSource.java:291)
        at
org.geotools.jdbc.JDBCDataStore.createFeatureSource(JDBCDataStore.java:767)
        at
org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:384)
        at
org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:349)
        at
org.geotools.data.store.ContentDataStore.getFeatureSource(ContentDataStore.java:102)
        at ConnectionDB.main(ConnectionDB.java:59)
Exception in thread "main" java.lang.UnsupportedOperationException: No style
method for com.vividsolutions.jts.geom.Geometry
        at org.geotools.styling.SLD.createSimpleStyle(SLD.java:1967)
        at org.geotools.styling.SLD.createSimpleStyle(SLD.java:1923)
        at
org.geotools.map.DefaultMapContext.checkStyle(DefaultMapContext.java:389)
        at 
org.geotools.map.DefaultMapContext.addLayer(DefaultMapContext.java:222)
        at ConnectionDB.main(ConnectionDB.java:70)
I hope you will give me some help!!!!

--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/mysql2shape-problems-tp6467339p6469355.html
Sent from the geotools-gt2-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to