[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 =
37995";

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;
System.out.println("<OUTPUT>");

while ((line = br.readLine()) != null)
    System.out.println(line);

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


And the result is:

<OUTPUT>
Preparing table for user query... Done.
Initializing...  coordinates: no such attribute in table
__pgsql2shp14493_tmp_table
</OUTPUT>

Does anybody as any idea about it?

Thank you for all

Best regards
-- 
Rogério De Pieri  (Lelo)
SCJP 5
Buscando melhorar a cada dia
Áudio, Hardware & Software
www.twitter.com/lelopieri
blogdolelo.wordpress.com
-------------- 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