Обсуждение: JDBC Array and PostgreSQL driver

Поиск
Список
Период
Сортировка

JDBC Array and PostgreSQL driver

От
Christopher BROWN
Дата:
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