Re: shp2pgsql in java - Mailing list pgsql-novice

From Michael Wood
Subject Re: shp2pgsql in java
Date
Msg-id 5a8aa6680909172355t4b1899c7yc9fd88fdd835e49@mail.gmail.com
Whole thread Raw
In response to shp2pgsql in java  (Melanie Hofmann <melanie.hofmann20@googlemail.com>)
List pgsql-novice
2009/9/18 Melanie Hofmann <melanie.hofmann20@googlemail.com>:
> Hello,
>
> I am new in this list.
> Sorry for my worse english.
>
> I have a problem, and I didn't find a answer in the Internet.
>
> I will use the command shp2pgsql from a java programm to import shapefiles
> in a postgresql DB, but I can't find some examples.
>
> Can anybody help me, or have anybody an example how this work? or a
> documentation?
>
> Thank you for your answer.

I think you basically want to set up a shell pipeline from Java.

You could either execute shp2pgsql from Java and arrange for its
stdout file descriptor to be pointing at a file and then execute psql
to read from that same file, or you could do it in one step by
connecting the stdout of shp2pgsql to the stdin of psql.

From Python, this is one way to do it.  (It should work from Jython
too, I think):
http://docs.python.org/library/subprocess.html#replacing-shell-pipeline

From Java you might find something useful here:
http://www.google.co.za/search?q=java+execute+shell+command

--
Michael Wood <esiotrot@gmail.com>

pgsql-novice by date:

Previous
From: Michael Wood
Date:
Subject: Re: Problem of creating geometry column (linestring)
Next
From: Ron Arts
Date:
Subject: Index not used in join.. (example included)