Re: Strange error when using varbit - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Strange error when using varbit
Date
Msg-id 43095D86.8060106@opencloud.com
Whole thread Raw
In response to Strange error when using varbit  (Maciej Jaźwiński <maciejjazwinski@interia.pl>)
List 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

pgsql-jdbc by date:

Previous
From: Maciej Jaźwiński
Date:
Subject: Strange error when using varbit
Next
From: Kris Jurka
Date:
Subject: Re: Czech translation