pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Selinger <d.selinger@focusmr.com>
To: pgsql-jdbc@postgresql.org
Subject: createArrayOf("bytea", Array<byte[]>) problem
Date: Fri, 14 Feb 2014 12:14:18 +0100
Message-ID: <52FDFA8A.8040707@focusmr.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

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?







-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc



view thread (3+ messages)  latest in thread

Message-ID: <52FDFA8A.8040707@focusmr.com>
Permalink:  ../52FDFA8A.8040707@focusmr.com/
Also on:    postgresql.org/message-id/52FDFA8A.8040707@focusmr.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: d.selinger@focusmr.com
  Subject: Re: createArrayOf("bytea", Array<byte[]>) problem
  In-Reply-To: <52FDFA8A.8040707@focusmr.com>
  References: <52FDFA8A.8040707@focusmr.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox