Cedric Briançon | 5 Apr 2006 14:48
Picon

Re: Problem when importing data from a shape file to a postgis DB

Cedric Briançon a écrit :

>Hello,
>
>I'm trying to import data stored in a shape file into a postgis
>database, but I'm getting this exception (AM_HYDRO_LIN_polyline is the
>name of my table, the same as the name of my shape file) :
>
>org.geotools.data.DataSourceException: Could not create
>AM_HYDRO_LIN_polyline out of provided feature: AM_HYDRO_LIN_polyline.1
>    at
>org.geotools.data.jdbc.JDBCFeatureStore.addFeatures(JDBCFeatureStore.java:331)
>    at Synchro.AlgoSynchro.fillTable(AlgoSynchro.java:206)
>    at Synchro.AlgoSynchro.searchLakingTables(AlgoSynchro.java:112)
>    at Synchro.AlgoSynchro.<init>(AlgoSynchro.java:94)
>    at Synchro.SynchroGIS.<init>(SynchroGIS.java:109)
>    at Synchro.SynchroGIS.main(SynchroGIS.java:239)
>Caused by: IllegalAttribute: null , but got null
>    at
>org.geotools.feature.DefaultFeature.setAttributes(DefaultFeature.java:251)
>    at
>org.geotools.data.jdbc.JDBCFeatureStore.addFeatures(JDBCFeatureStore.java:329)
>    ... 5 more
>
>I don't know if it has a link, but in my features, some fields are
>empty, consequently there would be a column in my table with null
>values. Here is my code :
>       
>        FeatureCollection collection = fsShape.collection();
>        PostgisDataStoreFactory factory = new PostgisDataStoreFactory();
>        PostgisDataStore dataStore = (PostgisDataStore)
>factory.createDataStore(connec);         
>        FeatureStore featureStore =
>(FeatureStore)dataStore.getFeatureSource(tableName);
>        FeatureReader reader = DataUtilities.reader(collection);
>        featureStore.addFeatures(reader);  // Exception here
>
>Thanks for your answers
>
>Cedric
>  
>
I get this error again when I try to import data in my shape file to a
PostGIS database. I really need an explanation of what is happening when
I try to use the method addFeatures(reader)...
I have tried to import data from a shape file that I know all fields are
filled, so there's no null values in it, but I get the same exception again.
I'm using the trunk version of geotools, and I now have some problems to
build the module trunk/gt/plugin/postgis :

[INFO]
----------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO]
----------------------------------------------------------------------------
[INFO] Compilation failure

/home/cedric/tmp/src/org/geotools/filter/SQLEncoderPostgis.java:[240,37]
cannot find symbol
symbol  : class LiteralExpression
location: class org.geotools.filter.SQLEncoderPostgis

[INFO]
----------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:552)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:472)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:451)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:303)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:270)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:139)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException:
Compilation failure
        at
org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:429)
        at
org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:110)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:415)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:531)
        ... 16 more

...
Cédric

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642

Gmane