pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-jdbc@postgresql.org
Subject: Re: BLOB help - yes I've read around!
Date: Tue, 07 Apr 2009 16:39:06 +0200
Message-ID: <grfoia$t7m$1@ger.gmane.org> (raw)
In-Reply-To: <49DB5D63.5040103@yahoo.co.uk>
References: <49DB559F.3030805@yahoo.co.uk>
	<200904071657.08065.achill@matrix.gatewaynet.com>
	<49DB5D63.5040103@yahoo.co.uk>

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




view thread (10+ messages)  latest in thread

Message-ID: <grfoia$t7m$1@ger.gmane.org>
Permalink:  ../grfoia$t7m$1@ger.gmane.org/
Also on:    postgresql.org/message-id/grfoia$t7m$1@ger.gmane.org

 · 

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: spam_eater@gmx.net
  Subject: Re: BLOB help - yes I've read around!
  In-Reply-To: <grfoia$t7m$1@ger.gmane.org>
  References: <49DB559F.3030805@yahoo.co.uk> <200904071657.08065.achill@matrix.gatewaynet.com> <49DB5D63.5040103@yahoo.co.uk> <grfoia$t7m$1@ger.gmane.org>

* 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