Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: jdbc setBinaryStream Date: Sat, 29 Nov 2014 19:59:14 +0000 (UTC) Organization: A noiseless patient Spider Lines: 25 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sat, 29 Nov 2014 19:59:14 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="12689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SCFYW5YBaH3F6mzVrFjkXOS5iUHw0Tag=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:uQVhp8k2SCjCd5LwlkFxlhiWi+o= Xref: csiph.com comp.lang.java.programmer:30448 On Sat, 29 Nov 2014 14:45:42 +0000, Andreas Leitgeb wrote: > Has anyone else run into that problem and perhaps found a solution? > I had a similar problem some time back when I was writing my mail archiving system, which stores archived e-mail in a PostgreSQL database using text fields to store the message body and a subset of it that contains searchable text. Text fields can contain arbitrary amounts of text: there is no way to specify a size for a text field. I think other databases call them CLOBs (Character Large Objects). The issue was with moving data into and out of these text text fields: the only JDBC interface for this data type is via an input or output Stream. I ended using ByteArrayOutputStreams to suck the data out of text columns into byte[] arrays and ByteArrayInputStreams to push data into them. This took a fair bit of head scratching to get it working since I kept thinking that the names of these classes were backward: wouldn't you expect a ByteArrayOutputStream to drain the byte array rather than fill it? -- martin@ | Martin Gregorie gregorie. | Essex, UK org |