JDBC Array and PostgreSQL driver

From: Christopher BROWN <brown(at)reflexe(dot)fr>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: JDBC Array and PostgreSQL driver
Date: 2017-01-26 15:50:21
Message-ID: CAHL_zcO3f+3cuJMCcj7y9Pc28SMk8NbbvyVaL+e8f6kFVAeW2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I'm just starting to use the ARRAY type (mainly to get all values of what
would otherwise be subqueries against "child" tables, referring to the
"current" table using foreign keys). Seems (so far) straightforward
enough, but I've not a lot of complete reference information out there.

For example, SELECTs seem to return Integer[] (when calling
resultSet.getArray("array_column").getArray()). The JDBC tutorial
indicates I should call "free()" on the array, but I can't figure out if
that's just a warning for batch update resource usage. Is this necessary
for result sets?

Furthermore, is the type mapping documented somewhere? For example, should
I use trial and error to figure out if for updates I should use int[] or
Integer[]?

Also, are there any downsides (performance and resource usage) for the
use-case I cited at the start? Previously, I ran two requests (one to
select "parent" records", and one to select "child" records, and then
associated the foreign keys in application code). I discovered that
"getArray()" returns an Integer[] in the debugger, and noticed that the
value seems to be held in a string (Jdbc4Array.fieldString).

Thanks for any advice,
Christopher

Browse pgsql-jdbc by date

  From Date Subject
Next Message joseph howard 2017-01-31 15:38:47 Please consider adding a getOpenCursors() or some such from the jdbc connection
Previous Message Al Presseller 2017-01-25 19:09:24 Re: "Cached plan must not change result type" error when switching search_path via explicit execution of SET SEARCH_PATH = ...