Re: Postgresql - COPY TO - get number row inserted - from JDBC - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Postgresql - COPY TO - get number row inserted - from JDBC
Date
Msg-id mb5bku$esq$1@ger.gmane.org
Whole thread Raw
In response to Postgresql - COPY TO - get number row inserted - from JDBC  (Nicolas Paris <niparisco@gmail.com>)
Responses Re: Postgresql - COPY TO - get number row inserted - from JDBC
List pgsql-general
Nicolas Paris wrote on 07.02.2015 15:14:
> Hello !
>
> My goal is to get the result from "COPY TO ..."  query, from JDBC. This query returns : COPY X
> (where X is number line inserted)
> 1) Can I can I consider it useless, since when no error, all lines are suposed to be inserted ?
> 2) If not useless, how can I get the response "COPY 10" (when 10 rows inserted), I get with psql way, or with
pgadmin.
>
> I have tried the int Statement.executeUpdate() method, but it returns 0
>
> Thanks for any help !
>
> Nicolas PARIS

I you are using COPY to import a file located on the server, I don't think you'll get that information from JDBC.

But you can use the equivalent to "COPY .. FROM stdin" through JDBC.
And when you do that, you can get the number of rows inserted:

https://jdbc.postgresql.org/documentation/publicapi/org/postgresql/copy/CopyManager.html



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Postgresql - COPY TO - get number row inserted - from JDBC
Next
From: Nicolas Paris
Date:
Subject: Re: Postgresql - COPY TO - get number row inserted - from JDBC