Received: from mta6.snfc21.pbi.net (mta6.snfc21.pbi.net [206.13.28.240]) by hub.org (8.10.1/8.10.1) with ESMTP id e7IMMEm23016 for ; Fri, 18 Aug 2000 18:22:14 -0400 (EDT) Received: from Mattathome ([206.170.32.215]) by mta6.snfc21.pbi.net (Sun Internet Mail Server sims.3.5.2000.01.05.12.18.p9) with SMTP id <0FZI00LSTE1XH2@mta6.snfc21.pbi.net> for pgsql-interfaces@postgresql.org; Fri, 18 Aug 2000 15:20:22 -0700 (PDT) Date: Fri, 18 Aug 2000 15:23:11 -0700 From: Matthew Orzen Subject: Storing and accessing bitmaps in the database w/JDBC To: pgsql-interfaces@postgresql.org Message-id: <004101c00962$e554d180$fd01aace@Mattathome> MIME-version: 1.0 X-Mailer: Microsoft Outlook Express 5.00.2919.6700 Content-type: text/plain; charset="iso-8859-1" Content-transfer-encoding: 7bit X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 X-Priority: 3 X-Archive-Number: 200008/110 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.