Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 1F16D6330FF for ; Tue, 7 Apr 2009 18:33:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 35396-07 for ; Tue, 7 Apr 2009 18:32:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp108.mail.mud.yahoo.com (smtp108.mail.mud.yahoo.com [209.191.85.218]) by mail.postgresql.org (Postfix) with SMTP id 19D506325FD for ; Tue, 7 Apr 2009 18:33:03 -0300 (ADT) Received: (qmail 45365 invoked from network); 7 Apr 2009 21:33:02 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Received:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=E1BuD6g9xpixx4crl4kXV8QqjwcuS51yxljCdbNmWZ0kVuRahQ1KBPWumWrU9J9vglrhuZVAJuPlgyQffKx2z/tvMvtj+Tcw59TkJMdjgQwwY9pMnGDx2jU4M1RcDwT0jbRXm5PLcCJ5gTrSOPPHinvLpbG48g4r0DjAGuUu0rE= ; Received: from unknown (HELO ?192.168.1.2?) (mail_4brad@121.73.20.162 with plain) by smtp108.mail.mud.yahoo.com with SMTP; 7 Apr 2009 21:33:01 -0000 X-YMail-OSG: skus0ngVM1mbMUlIA8eSKasJU0itrjclfmoEBZHOw4mmLUFupmpU4U.3gIuB4EsjAR6cLAE4Cw7M_qHJnhigvPLGDG5mH10FMBZU5yHZC67aNFgc.h.HwOMX85fl4y_YAuH8YtJjRdT2IOHaHlLVf8vsSyA9PSf3pUeBPAOwf_swjg79nb1TIB5WkUsl9d0VQKNtOb0rbJlwePXjjiAWJteVUUdt6tJMl1mo.EWbkGm5mILrnypkO1aL4OPBgmWVlV1WTAkswUUcdJFj X-Yahoo-Newman-Property: ymail-3 Message-ID: <49DBC6DC.5030609@yahoo.co.uk> Date: Wed, 08 Apr 2009 09:34:20 +1200 From: Brad Milne User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org CC: Thomas Kellerer , Achilleas Mantzios Subject: Re: BLOB help - yes I've read around! References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL=0.001 X-Spam-Level: X-Archive-Number: 200904/25 X-Sequence-Number: 19472 Thanks to you both This works for me Thomas. For completeness, here is the setter again with a couple of fixes: stmt.setBinaryStream(2,in,in.available()); or optionally (if it is a file): stmt.setBinaryStream(2,in,blobFile.length()); Thomas Kellerer wrote: > Brad Milne, 07.04.2009 16:04: >> So how do you save the bytea data? I get: >> Method >> org.postgresql.jdbc4.Jdbc4PreparedStatement.setBinaryStream(int, >> InputStream) is not yet implemented >> > > The following has been working for me since I think 8.1 (and the > corresponding JDBC driver): > > Statement stmt = con.prepareStatement( > "INSERT INTO blob_table (id, blob_col) VALUES (?,?)"); > stmt.setInt(1, 42); > > File blobFile = new File("my_picture.jpg"); > InputStream in = new FileInputStream(blobFile); > stmt.setBinaryStream(2, r, (int)f.length()); > stmt.executeUpdate(); > con.commit(); > > Thomas > >