pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Maciej Jaźwiński <maciejjazwinski@interia.pl>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Strange error when using varbit
Date: Mon, 22 Aug 2005 17:07:18 +1200
Message-ID: <43095D86.8060106@opencloud.com> (raw)
In-Reply-To: <001401c5a54b$efe43d90$6302040a@javaone>
References: <001401c5a54b$efe43d90$6302040a@javaone>

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



view thread (2+ messages)

Message-ID: <43095D86.8060106@opencloud.com>
Permalink:  ../43095D86.8060106@opencloud.com/
Also on:    postgresql.org/message-id/43095D86.8060106@opencloud.com

 · 

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: oliver@opencloud.com, maciejjazwinski@interia.pl
  Subject: Re: Strange error when using varbit
  In-Reply-To: <43095D86.8060106@opencloud.com>
  References: <001401c5a54b$efe43d90$6302040a@javaone> <43095D86.8060106@opencloud.com>

* 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