[postgis-users] pgsql2shp using java ProcessBuilder

Lelo - Luiz Rogério De Pieri lelo.pieri at gmail.com
Thu Apr 4 08:21:36 PDT 2013

Hi all,

I'm having a problem to execute a pgsql2shp command using java.

My OS is Ubuntu and it's frequently I use to generate shp files using
pgsql2shp, but now I want to do it through java.

The follow command works fine on terminal
pgsql2shp -f pontos_05600202_teste -h myhost -u myuser -P mypasswd -g
coordinates my_database "SELECT * from points where id_uploaded_file =

Now I'm trying to execute the follow code:

ProcessBuilder pb = new ProcessBuilder("pgsql2shp", "-f
pontos_05600202_teste", "-h myhost", "-u myuser", "-P mypasswd", "-g
coordinates", "my_database", "SELECT coordinates, date from points where
id_uploaded_file = 37995");

Process proc;
proc = pb.start();
InputStream stdin = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(stdin);
BufferedReader br = new BufferedReader(isr);

String line = null;

while ((line = br.readLine()) != null)

int exitVal = proc.waitFor();
System.out.println("Process exitValue: " + exitVal);

And the result is:

Preparing table for user query... Done.
Initializing...  coordinates: no such attribute in table

Does anybody as any idea about it?

Thank you for all

Best regards
Rogério De Pieri  (Lelo)
Buscando melhorar a cada dia
Áudio, Hardware & Software
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130404/78b07e76/attachment.html>

More information about the postgis-users mailing list