Re: Selecting large objects stored as bytea - Mailing list pgsql-general

From Richard Huxton
Subject Re: Selecting large objects stored as bytea
Date
Msg-id 47BEB14D.2020309@archonet.com
Whole thread Raw
In response to Selecting large objects stored as bytea  ("Ludger Zachewitz" <ludger.zachewitz@gmx.de>)
List 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

pgsql-general by date:

Previous
From: "Ludger Zachewitz"
Date:
Subject: Selecting large objects stored as bytea
Next
From: Howard Wilkinson
Date:
Subject: Re: Querying the schema for column widths - what syntax do I use?