Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

problem importing point shapefile to postgis

hi all,
importing the stations shapefile (from the demo dataset) to postgis gives this strange error output
Starting job shp2pg at 17:20 12/03/2012.
connecting to socket on port 3685
connected
INFO: Table public.stations dropped.
Exception in component sPostgisOutput_1_SO
java.io.IOException: Feature writer is closed
at org.geotools.data.jdbc.JDBCFeatureWriter.hasNext(JDBCFeatureWriter.java:338)
at org.geotools.data.jdbc.JDBCFeatureWriter.next(JDBCFeatureWriter.java:81)
at org.geotools.data.jdbc.JDBCFeatureWriter.next(JDBCFeatureWriter.java:48)
at org.geotools.data.InProcessLockingManager$1.next(InProcessLockingManager.java:312)
at org.geotools.data.InProcessLockingManager$1.next(InProcessLockingManager.java:304)
at talenddemosjava.shp2pg_0_1.shp2pg.sShapefileInput_1_GIProcess(shp2pg.java:1309)
at talenddemosjava.shp2pg_0_1.shp2pg.runJobInTOS(shp2pg.java:1641)
at talenddemosjava.shp2pg_0_1.shp2pg.main(shp2pg.java:1509)
Source CRS is: GEOGCS],
PRIMEM,
UNIT,
AXIS,
AXIS]
2012-03-12 17:20:08,795 ERROR SQL Exception writing geometry columnERROR: new row for relation "stations" violates check constraint "enforce_geotype_the_geom"
org.postgresql.util.PSQLException: ERROR: new row for relation "stations" violates check constraint "enforce_geotype_the_geom"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1525)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1309)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:340)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:286)
at org.apache.commons.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:228)
at org.geotools.data.jdbc.JDBCTextFeatureWriter.doInsert(JDBCTextFeatureWriter.java:118)
at org.geotools.data.jdbc.JDBCFeatureWriter.write(JDBCFeatureWriter.java:215)
at org.geotools.data.InProcessLockingManager$1.write(InProcessLockingManager.java:331)
at talenddemosjava.shp2pg_0_1.shp2pg.sShapefileInput_1_GIProcess(shp2pg.java:1339)
at talenddemosjava.shp2pg_0_1.shp2pg.runJobInTOS(shp2pg.java:1641)
at talenddemosjava.shp2pg_0_1.shp2pg.main(shp2pg.java:1509)
SQL Exception writing geometry columnERROR: new row for relation "stations" violates check constraint "enforce_geotype_the_geom"
disconnected
2012-03-12 17:20:09,025 ERROR The following locker still has a lock read on file:/data/tos/SdiDemoGeoData-V1.1/station.shp by org.geotools.data.shapefile.shp.ShapefileReader
it was created with the following stack trace
org.geotools.data.shapefile.ShpFilesLocker$Trace: Locking file:/data/tos/SdiDemoGeoData-V1.1/station.shp for read by org.geotools.data.shapefile.shp.ShapefileReader in thread main
at org.geotools.data.shapefile.ShpFilesLocker.setTraceException(ShpFilesLocker.java:53)
at org.geotools.data.shapefile.ShpFilesLocker.(ShpFilesLocker.java:32)
at org.geotools.data.shapefile.ShpFiles.acquireRead(ShpFiles.java:352)
at org.geotools.data.shapefile.ShpFiles.getReadChannel(ShpFiles.java:747)
at org.geotools.data.shapefile.shp.ShapefileReader.(ShapefileReader.java:142)
at org.geotools.data.shapefile.ShapefileDataStore.openShapeReader(ShapefileDataStore.java:421)
at org.geotools.data.shapefile.ShapefileDataStore.getAttributesReader(ShapefileDataStore.java:407)
at org.geotools.data.shapefile.ShapefileDataStore.getFeatureReader(ShapefileDataStore.java:327)
at org.geotools.data.shapefile.ShapefileDataStore.getFeatureReader(ShapefileDataStore.java:322)
at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:419)
at org.geotools.data.shapefile.ShapefileDataStore.getFeatureReader(ShapefileDataStore.java:372)
at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:385)
at org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:210)
at org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:227)
at org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:197)
at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:186)
at talenddemosjava.shp2pg_0_1.shp2pg.sShapefileInput_1_GIProcess(shp2pg.java:1177)
at talenddemosjava.shp2pg_0_1.shp2pg.runJobInTOS(shp2pg.java:1641)
at talenddemosjava.shp2pg_0_1.shp2pg.main(shp2pg.java:1509)
2012-03-12 17:20:09,025 ERROR The following locker still has a lock read on file:/data/tos/SdiDemoGeoData-V1.1/station.dbf by org.geotools.data.shapefile.dbf.DbaseFileReader
it was created with the following stack trace
org.geotools.data.shapefile.ShpFilesLocker$Trace: Locking file:/data/tos/SdiDemoGeoData-V1.1/station.dbf for read by org.geotools.data.shapefile.dbf.DbaseFileReader in thread main
at org.geotools.data.shapefile.ShpFilesLocker.setTraceException(ShpFilesLocker.java:53)
at org.geotools.data.shapefile.ShpFilesLocker.(ShpFilesLocker.java:32)
at org.geotools.data.shapefile.ShpFiles.acquireRead(ShpFiles.java:352)
at org.geotools.data.shapefile.ShpFiles.getReadChannel(ShpFiles.java:747)
at org.geotools.data.shapefile.dbf.DbaseFileReader.(DbaseFileReader.java:130)
at org.geotools.data.shapefile.ShapefileDataStore.openDbfReader(ShapefileDataStore.java:446)
at org.geotools.data.shapefile.ShapefileDataStore.getAttributesReader(ShapefileDataStore.java:407)
at org.geotools.data.shapefile.ShapefileDataStore.getFeatureReader(ShapefileDataStore.java:327)
at org.geotools.data.shapefile.ShapefileDataStore.getFeatureReader(ShapefileDataStore.java:322)
at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:419)
at org.geotools.data.shapefile.ShapefileDataStore.getFeatureReader(ShapefileDataStore.java:372)
at org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:385)
at org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:210)
at org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:227)
at org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:197)
at org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:186)
at talenddemosjava.shp2pg_0_1.shp2pg.sShapefileInput_1_GIProcess(shp2pg.java:1177)
at talenddemosjava.shp2pg_0_1.shp2pg.runJobInTOS(shp2pg.java:1641)
at talenddemosjava.shp2pg_0_1.shp2pg.main(shp2pg.java:1509)
2012-03-12 17:20:09,031 ERROR There's code using JDBC based datastore and not disposing them. This may lead to temporary loss of database connections. Please make sure all data access code calls DataStore.dispose() before freeing all references to it
Job shp2pg ended at 17:20 12/03/2012.

if am trying to import a copy of the stations dataset (because of the strange locking messages above) it is exactly the same. if i change the geometry type from POINT to MULTIPOINT or even LINESTRING it works
Starting job shp2pg at 17:22 12/03/2012.
connecting to socket on port 3634
connected
INFO: Table public.stations dropped.
Source CRS is: GEOGCS],
PRIMEM,
UNIT,
AXIS,
AXIS]
disconnected
Job shp2pg ended at 17:23 12/03/2012.
any help appreciated
christian
p.s. importing the CCMRIVERS.shp or gboundaries.shp works fine (after removing the attributes with the type LONG)

Labels (2)
2 Replies
Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

Hello all
I am importing shape file to my application iam getting a message posted below in the console but no error is coming shape file importing correctly.

ug 23, 2013 1:39:16 PM org.geotools.data.shapefile.ShpFiles logCurrentLockers
SEVERE: The following locker still has a lock: read on file:/home/snk/land/sss.shp by org.geotools.data.shapefile.shp.ShapefileReader
Aug 23, 2013 1:39:16 PM org.geotools.data.shapefile.ShpFiles logCurrentLockers
SEVERE: The following locker still has a lock: read on file:/home/snk/land/sss.shx by org.geotools.data.shapefile.shp.IndexFile
Aug 23, 2013 1:39:16 PM org.geotools.data.shapefile.ShpFiles logCurrentLockers
SEVERE: The following locker still has a lock: read on file:/home/snk/land/sss.dbf by org.geotools.data.shapefile.dbf.DbaseFileReader
Aug 23, 2013 1:39:16 PM org.geotools.data.shapefile.ShpFiles logCurrentLockers
SEVERE: The following locker still has a lock: read on file:/home/snk/land/sss.shp by org.geotools.data.shapefile.shp.ShapefileReader
Aug 23, 2013 1:39:16 PM org.geotools.data.shapefile.ShpFiles logCurrentLockers
SEVERE: The following locker still has a lock: read on file:/home/snk/land/sss.shx by org.geotools.data.shapefile.shp.IndexFile
Aug 23, 2013 1:39:16 PM org.geotools.data.shapefile.ShpFiles logCurrentLockers
SEVERE: The following locker still has a lock: read on file:/home/snk/land/sss.dbf by org.geotools.data.shapefile.dbf.DbaseFileReader

i tried to solve it but i have not got the solution on the web . please help me i am pasting the code below
public boolean openShapeFile() throws Exception
{
File dataFile = new File(FileNames);
ShapefileDataStore store = new IndexedShapefileDataStore(dataFile.toURI().toURL());
SimpleFeatureSource source = store.getFeatureSource();
final SimpleFeatureCollection featureCollection = source.getFeatures();
simpleFeatureIterator = featureCollection.features();
return true;
}
here i am iterating through simpleFeatureIterator

thanks and regards.