Re: Strange error when using varbit

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Maciej Jaźwiński <maciejjazwinski(at)interia(dot)pl>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Strange error when using varbit
Date: 2005-08-22 05:07:18
Message-ID: 43095D86.8060106@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Maciej Jaźwiński wrote:

> I have a problem with varbit and blobs. I need to upload binary files to
> my database, and yesterday I've got it working.... for an hour or two.
> Files were uploaded, but image (which I tried to download then was
> corrupted). But the worst came later, postgres started to throw
> exceptions at me :( Help, this is part of my diploma, and i really need
> to get it working..

> org.postgresql.util.PSQLException: ERROR: "%" is not a valid binary digit

> String update = "insert into resources (resources_id, projects_id,
> requirements_id, " +
> "filename, content_type, filesize, file) values (?, ?, ?, ?, ?, ?, ?)";

What is the definition of the 'resources' table?

I suspect from your description and the error that you are getting
confused between bit(n) (bit string) and bytea (binary data). For your
application it sounds like you want to use bytea. There's no direct
mapping of bit(n) types in JDBC.

See http://www.postgresql.org/docs/8.0/static/datatype-binary.html and
http://www.postgresql.org/docs/8.0/static/datatype-bit.html.

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2005-08-22 06:07:26 Re: Czech translation
Previous Message Petr Dittrich 2005-08-21 19:12:41 Czech translation