Обсуждение: createArrayOf("bytea", Array) problem

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

createArrayOf("bytea", Array) problem

От
Daniel Selinger
Дата:
Hi all,

I have a problem with submitting arrays of bytea to the database via
native jdbc arrays.

i'm trying to do the following:

List<byte[]> hashes = new ArrayList<>();
//add some SHA256 in form of byte[]
srcPst = srcConnection.prepareStatement("select array_dims(?)");
srcPst.setArray(1, srcConnection.createArrayOf("bytea", hashes.toArray()));
srcRs = srcPst.executeQuery();
srcRs.next();
srcRs.getString(1);

--> "[1:5][1:32]"


if i do the same thing on the database:

select array_dims(array_agg(hashcolumn)) from hashtable; (hashcolumn is
of type bytea(32))

--> "[1:5]"


now im struggling how to use the bound data from jdbc on the database,
because when i use the "[1:5][1:32]" array on the database for something
like

select * from hashtable where hashcolumn = ANY(?), i get no results,
although i retrieved the hashes from a resultset on exaclty this table
with getBytes("hashcolumn")


any suggestions or hints on what i might doing wrong?