What's the best approach to import a user uploaded shapefile into an Oracle DB? The dbf, shx and shp files of the Shapefile come in a ZIP Archive.

Currently, we unzip programatically and then parse the dbf, shx and shp files manually using custom Java and the GeoTools library. From this we build SQL Strings to create the table and insert the values. This works, but seems cumbersome given the complexity of shapefiles.

I thought that there must be an easier way of just using some kind of Java library to which we pass the shapefile. The library should just take care of all the shapefile import stuff.

However, I do not find any GeoTools method for simply importing a Shapefile into a Oracle DB. I only found this Oracle Java Program, but no tutorials on how to use this as part of a java based web portal.

2 Answers 2


This is a simple operation in GeoTools, once you have read in the Shapefile you will have a FeatureCollection which you just need to write to an Oracle Datastore.

I have an example of how to write a Database (mysql and postgis are the examples included) here.


Oracle Spatial comes with a collection of Java APIs, and one of them lets you read shapefiles. That API is documented here: http://docs.oracle.com/database/121/SPAJV/toc.htm. Look for the oracle.spatial.util package, specifically class ShapefileFeatureJGeom. It uses lower level classes that perform the actual reading of the shapefile (DBFReaderJGeom and ShapefileFeatureJGeom). That API is used by Mapbuilder and is also used by the command-line program you indicate (SampleShapefileToJGeomFeature).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.