From: Matthew Orzen <morzen@pacbell.net>
To: pgsql-interfaces@postgresql.org
Subject: Storing and accessing bitmaps in the database w/JDBC
Date: Fri, 18 Aug 2000 15:23:11 -0700
Message-ID: <004101c00962$e554d180$fd01aace@Mattathome> (raw)
Hi,
I'm having trouble converting bit maps to a form that I can store in the
database. Here is part of a test app I've been messin' with.
String binString = new String("101010100011001111100011");
int byteCount = 3;
byte[] byteArray = new byte[byteCount];
// build a byte array
int bitCount = 0;
for (int i = 0; i < byteCount, i++)
{
Integer val = Integer.valueOf(bin.substring(bitCount, bitCount + 8,
2);
bitCount += 8;
byteArray[i] = val.byteValue();
}
// store it in the database
PreparedStatemept p = conn.prepareStatement("Insert into table1 (mapval)
values (?)");
p.setBytes(1, byteArray);
p.executeUpdate()
I'm getting the following exception
Attribute 'mapval' is of type 'bytea' but expression is of type 'int4'
You will need to rewrite or cast the expression
On a related note, I'm a little unclear about bytea. Is bytea data always
stored as a large object ?
Thanks for the help.
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: morzen@pacbell.net
Subject: Re: Storing and accessing bitmaps in the database w/JDBC
In-Reply-To: <004101c00962$e554d180$fd01aace@Mattathome>
* 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