Re: bytea problem

From: "Mikael" <mikael-aronsson(at)telia(dot)com>
To: "alkampfer" <kazucat(at)gmail(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: bytea problem
Date: 2011-11-22 17:54:00
Message-ID: C0D3A9F601FC450E8618CAB7327C7925@emea.itt.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Is this a typo or is the code like this ?

ps.setBytes(2,bytes);
ps.setString(2,id);

----- Original Message -----
From: "alkampfer" <kazucat(at)gmail(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Sent: Tuesday, November 22, 2011 6:37 PM
Subject: [JDBC] bytea problem

> Hello, this is my problem :
> I use java + postgres and I want to store image files into a table
>
> my table : (id int, image bytea)
>
> the code :
> byte bytes[] = new byte[(int)file.length()];
>
> sqlq ="UPDATE table set image= ? where id=?";
> ps = .....prepareStatement(sqlq);
> ps.setBytes(2,bytes);
> ps.setString(2,id);
>
> put the file into my table, stream of 41054 bytes, OK.
>
> but when I retrieve it from the database resultSet.getBytes("image") gives
> an array of 82108 bytes!!
> worst of all those bytes I get have no sense at all, like 00 00 00 or 11
> 11....
>
> thanks for the help!
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/bytea-problem-tp5014176p5014176.html
> Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message alkampfer 2011-11-22 18:10:40 Re: bytea problem
Previous Message alkampfer 2011-11-22 17:37:30 bytea problem