Skip site navigation (1) Skip section navigation (2)

Storing and accessing bitmaps in the database w/JDBC

From: Matthew Orzen <morzen(at)pacbell(dot)net>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Storing and accessing bitmaps in the database w/JDBC
Date: 2000-08-18 22:23:11
Message-ID: 004101c00962$e554d180$fd01aace@Mattathome (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces

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,
       bitCount += 8;
       byteArray[i] = val.byteValue();

    // store it in the database
    PreparedStatemept p = conn.prepareStatement("Insert into table1 (mapval)
values (?)");
    p.setBytes(1, byteArray);

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.

pgsql-interfaces by date

Next:From: Josh BerkusDate: 2000-08-19 00:52:01
Subject: Re: MS Access problems
Previous:From: Tim UckunDate: 2000-08-18 21:42:17
Subject: Re: MS Access + Postgres

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group