Re: BLOB help - yes I've read around!

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: BLOB help - yes I've read around!
Date: 2009-04-07 14:39:06
Message-ID: grfoia$t7m$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2009-04-07 15:17:27 Re: Array passing
Previous Message Achilleas Mantzios 2009-04-07 14:29:44 Re: BLOB help - yes I've read around!