Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 8EBA86336B3 for ; Tue, 7 Apr 2009 11:39:27 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 44118-01 for ; Tue, 7 Apr 2009 11:39:25 -0300 (ADT) Received: from mx1.hub.org (mx1.hub.org [200.46.208.106]) by mail.postgresql.org (Postfix) with ESMTP id C6C526336AD for ; Tue, 7 Apr 2009 11:39:25 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mx1.hub.org (Postfix) with ESMTP id 4D5B2125A819 for ; Tue, 7 Apr 2009 11:39:25 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LrCSN-0002j1-3b for pgsql-jdbc@postgresql.org; Tue, 07 Apr 2009 14:39:19 +0000 Received: from 217.110.94.67 ([217.110.94.67]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Apr 2009 14:39:19 +0000 Received: from spam_eater by 217.110.94.67 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 07 Apr 2009 14:39:19 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Thomas Kellerer Subject: Re: BLOB help - yes I've read around! Date: Tue, 07 Apr 2009 16:39:06 +0200 Lines: 19 Message-ID: References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 217.110.94.67 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666 In-Reply-To: <49DB5D63.5040103@yahoo.co.uk> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.599 tagged_above=0 required=5 tests=RCVD_NUMERIC_HELO=2.599 X-Spam-Level: ** X-Archive-Number: 200904/19 X-Sequence-Number: 19466 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