Re: Selecting large objects stored as bytea

From: Richard Huxton <dev(at)archonet(dot)com>
To: Ludger Zachewitz <ludger(dot)zachewitz(at)gmx(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Selecting large objects stored as bytea
Date: 2008-02-22 11:26:05
Message-ID: 47BEB14D.2020309@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ludger Zachewitz wrote:
> Hello,
>
> I have the following problem accessing postgres (version: 8.2.X) from
> java 1.6_03 using driver (currently version:
> postgresql-8.2-508.jdbc4.jar) and hope someone can help me. I have
> created an table 'files' with the columns 'file_id', 'filename' and
> 'file_content'. 'file_content'is of type bytea and should store large
> binary files. A method for storing files in that table also exists
> and work fine.
>
> Now I am trying to select a stored 'file_content' from the table and
> store it directly on the filesystem. Because the files could be very
> large, i don't want to hold them in the main memory -- so I am using
> Input- and Outputstreams (see source code below).

If you don't want the whole field at once, you don't want a bytea. The
large-object interface offers lo_read/lo_write to let you grab data in
smaller chunks.

See the manuals for details, I'm afraid I'm not sure of the procedure
for accessing lo_read from JDBC.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Howard Wilkinson 2008-02-22 11:38:33 Re: Querying the schema for column widths - what syntax do I use?
Previous Message Ludger Zachewitz 2008-02-22 10:52:35 Selecting large objects stored as bytea