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

From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Cc: Brad Milne <mail_4brad(at)yahoo(dot)co(dot)uk>
Subject: Re: BLOB help - yes I've read around!
Date: 2009-04-07 13:57:07
Message-ID: 200904071657.08065.achill@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Στις Tuesday 07 April 2009 16:31:11 ο/η Brad Milne έγραψε:
> Hi all
>
> I'm a Java dev, new to postgres. I've just migrated an app during
> development from Derby to Postgres (due to better indexing features),
> but am very confused by the failing BLOB implementations.
>
> PostgreSQL: 8.3.7
> PostgreSQL-JDBC: 8.3-604
> JDK: 6
>
> A lot of what I've seen in searches and even in the google groups page,
> seems to be related to older jdbc drivers, where BLOBs were supported,
> both for OID and bytea. I'm currently getting 'unimplemented' exceptions
> doing anything with BLOBs.
>
> My application saves sound files as byte arrays to the database.
>
> Q1: Given that it's sound and not text, would it be safe to use bytea
> given that certain characters need to be escaped?

I have been storing binary data in bytea for ages with postgresql,
with no major problems.
Performance might be an issue.
It is a good practice to store along with the bytea value,
its mime type as well.
So in your binary library you could have mp3s,oggs,mpegs, ms docs, jpegs, pdfs,
and your servlet would know exactly the content type to serve to the client.

Also to answer your question about safeness/escaping, etc...
those are taken care by the jdbc driver.

> Q2: How on earth do I use the BLOB methods? In particular setBlob(int
> parameterIndex, InputStream inputStream) and/or createBlob() and
> setBlob(int parameterIndex, Blob x)?
>

I never did anything with BLOBs so no experience from me here.

> Thanks a lot
> Brad
>

--
Achilleas Mantzios

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Hannu Krosing 2009-04-07 14:02:53 Re: What do people use for connection pooling with PostgreSQL JDBC
Previous Message Hannu Krosing 2009-04-07 13:40:55 Re: What do people use for connection pooling with PostgreSQL JDBC