Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 48E139F37EF for ; Tue, 22 Nov 2011 13:56:27 -0400 (AST) Received: from smtp-out21.han.skanova.net ([195.67.226.208]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RSua1-0001an-LB for pgsql-jdbc@postgresql.org; Tue, 22 Nov 2011 17:56:26 +0000 Received: from W193MTEC (213.66.191.254) by smtp-out21.han.skanova.net (8.5.133) (authenticated as u35603170) id 4EC0B93A003A6981; Tue, 22 Nov 2011 18:56:12 +0100 Message-ID: From: "Mikael" To: "alkampfer" , References: <1321983450992-5014176.post@n5.nabble.com> Subject: Re: bytea problem Date: Tue, 22 Nov 2011 18:54:00 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 X-Archive-Number: 201111/66 X-Sequence-Number: 22401 Is this a typo or is the code like this ? ps.setBytes(2,bytes); ps.setString(2,id); ----- Original Message ----- From: "alkampfer" To: 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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-jdbc