pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedStreaming blob to db
6+ messages / 5 participants
[nested] [flat]
* Streaming blob to db
@ 2005-07-01 16:05 時期 精霊 <kuon@goyman.com>
2005-07-02 08:00 ` Re: Streaming blob to db Jesper Thorhauge <jth@conzentrate.com>
2005-07-04 09:33 ` Re: Streaming blob to db Kris Jurka <books@ejurka.com>
0 siblings, 2 replies; 6+ messages in thread
From: 時期 精霊 @ 2005-07-01 16:05 UTC (permalink / raw)
To: pgsql-jdbc
Hello,
I got a web application that use jdbc and that will need to stream
binary data to the database.
My application need an outputstream to send the data to the db, and
an inputstream to read the data from the db.
I seeked the web but I did not found any working example.
I use postgresql 8.0.1 with bytea field.
The data size will be around:
<1mb 50%
1 - 100mb 30%
>100mb 20%
Any idea of the best approach?
Regards
Kuon
Attachments:
smime.p7s (application/pkcs7-signature, 2.3K) download
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Streaming blob to db
2005-07-01 16:05 Streaming blob to db 時期 精霊 <kuon@goyman.com>
@ 2005-07-02 08:00 ` Jesper Thorhauge <jth@conzentrate.com>
1 sibling, 0 replies; 6+ messages in thread
From: Jesper Thorhauge @ 2005-07-02 08:00 UTC (permalink / raw)
To: 時期 精霊 <kuon@goyman.com>; +Cc: pgsql-jdbc
Hi Kuon
Use the standard jdbc method on a PreparedStatement, called
setBinaryStream(..) (using version 8.0.x of the driver). The bad thing
is that getting the data out from database using getBinaryStream(..)
will use a lot of memory relative to the filesize - there seems to be no
way to avoid this. Look elsewhere in the archives for an explanation by
Oliver on this issue...
Regards
Jesper
時期 精霊 wrote:
> Hello,
>
> I got a web application that use jdbc and that will need to stream
> binary data to the database.
>
> My application need an outputstream to send the data to the db, and
> an inputstream to read the data from the db.
>
> I seeked the web but I did not found any working example.
>
> I use postgresql 8.0.1 with bytea field.
>
> The data size will be around:
>
> <1mb 50%
> 1 - 100mb 30%
> >100mb 20%
>
> Any idea of the best approach?
>
> Regards
>
> Kuon
--
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Streaming blob to db
2005-07-01 16:05 Streaming blob to db 時期 精霊 <kuon@goyman.com>
@ 2005-07-04 09:33 ` Kris Jurka <books@ejurka.com>
2005-07-05 10:23 ` Re: Streaming blob to db 時期 精霊 <kuon@goyman.com>
1 sibling, 1 reply; 6+ messages in thread
From: Kris Jurka @ 2005-07-04 09:33 UTC (permalink / raw)
To: 時期 精霊 <kuon@goyman.com>; +Cc: pgsql-jdbc
On Fri, 1 Jul 2005, [UTF-8] æ^Y^Bæ^\^_ ç²¾é^\ wrote:
>
> I got a web application that use jdbc and that will need to stream
> binary data to the database.
>
> My application need an outputstream to send the data to the db, and
> an inputstream to read the data from the db.
>
> I use postgresql 8.0.1 with bytea field.
>
> >100mb 20%
>
If you are really dealing with 100+Mb files you should probably look into
using large objects instead of bytea storage. This will provide the
streaming interfaces you are looking for and avoid excessive memory usage.
http://jdbc.postgresql.org/documentation/80/binary-data.html
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Streaming blob to db
2005-07-01 16:05 Streaming blob to db 時期 精霊 <kuon@goyman.com>
2005-07-04 09:33 ` Re: Streaming blob to db Kris Jurka <books@ejurka.com>
@ 2005-07-05 10:23 ` 時期 精霊 <kuon@goyman.com>
2005-07-05 13:54 ` Re: Streaming blob to db Roland Walter <rwa@mosaic-ag.com>
0 siblings, 1 reply; 6+ messages in thread
From: 時期 精霊 @ 2005-07-05 10:23 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: pgsql-jdbc
How can I trigger the deletion of the large object when the row
containing the oid is deleted?
I mean I know that:
DELETE FROM pg_largeobject WHERE loid = nnn
But is there in jdbc, an automatic way to handle that?
Regards
Kuon
On Jul 4, 2005, at 11:33 AM, Kris Jurka wrote:
>
>
> On Fri, 1 Jul 2005, [UTF-8] æ^Y^Bæ^\^_ ç²¾é^\Š wrote:
>
>>
>> I got a web application that use jdbc and that will need to stream
>> binary data to the database.
>>
>> My application need an outputstream to send the data to the db, and
>> an inputstream to read the data from the db.
>>
>> I use postgresql 8.0.1 with bytea field.
>>
>>
>>> 100mb 20%
>>>
>>
>>
>
> If you are really dealing with 100+Mb files you should probably
> look into
> using large objects instead of bytea storage. This will provide the
> streaming interfaces you are looking for and avoid excessive memory
> usage.
>
> http://jdbc.postgresql.org/documentation/80/binary-data.html
>
> Kris Jurka
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Streaming blob to db
2005-07-01 16:05 Streaming blob to db 時期 精霊 <kuon@goyman.com>
2005-07-04 09:33 ` Re: Streaming blob to db Kris Jurka <books@ejurka.com>
2005-07-05 10:23 ` Re: Streaming blob to db 時期 精霊 <kuon@goyman.com>
@ 2005-07-05 13:54 ` Roland Walter <rwa@mosaic-ag.com>
2005-07-05 14:31 ` Re: Streaming blob to db Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Roland Walter @ 2005-07-05 13:54 UTC (permalink / raw)
To: 時期 精霊 <kuon@goyman.com>; +Cc: Kris Jurka <books@ejurka.com>; pgsql-jdbc
時期 精霊 schrieb:
> How can I trigger the deletion of the large object when the row
> containing the oid is deleted?
>
> I mean I know that:
> DELETE FROM pg_largeobject WHERE loid = nnn
>
> But is there in jdbc, an automatic way to handle that?
>
There is a vacuumlo program in the contrib directory of the
database source. If the contributed programs are installed you
should have it. The readme for it is usually installed in
the directory doc/contrib in the directory of the database installation.
--
Roland Walter phone: +49 (0) 22 25 / 88 2-41 1
MOSAIC SOFTWARE AG fax: +49 (0) 22 25 / 88 2-20 1
Am Pannacker 3 mailto: rwa (at) mosaic-ag (dot) com
D-53340 Meckenheim http://www.mosaic-ag.com
------- L E G A L D I S C L A I M E R ---------
Die Informationen in dieser Nachricht sind vertraulich
und ausschliesslich fuer den Adressaten bestimmt.
Kenntnisnahme durch Dritte ist unzulaessig. Die
Erstellung von Kopien oder das Weiterleiten an weitere,
nicht originaere und benannte Adressaten ist nicht
vorgesehen und kann ungesetzlich sein. Die Meinungen
in dieser Nachricht stellen lediglich die Meinungen
des Senders dar. Falls Sie vermuten, dass diese
Nachricht veraendert wurde, setzen Sie sich mit dem
Absender in Verbindung. Der Absender uebernimmt ohne
weitere Ueberpruefung keine Verantwortung fuer die
Richtigkeit und Vollstaendigkeit des Inhalts. Unbefugte
Empfaenger werden gebeten, die Vertraulichkeit der
Nachricht zu wahren und den Absender sofort ueber
einen Uebertragungsfehler zu informieren.
------------------------------------------------------
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Streaming blob to db
2005-07-01 16:05 Streaming blob to db 時期 精霊 <kuon@goyman.com>
2005-07-04 09:33 ` Re: Streaming blob to db Kris Jurka <books@ejurka.com>
2005-07-05 10:23 ` Re: Streaming blob to db 時期 精霊 <kuon@goyman.com>
2005-07-05 13:54 ` Re: Streaming blob to db Roland Walter <rwa@mosaic-ag.com>
@ 2005-07-05 14:31 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 2005-07-05 14:31 UTC (permalink / raw)
To: Roland Walter <rwa@mosaic-ag.com>; +Cc: 時期 精霊 <kuon@goyman.com>; Kris Jurka <books@ejurka.com>; pgsql-jdbc
Roland Walter <rwa@mosaic-ag.com> writes:
> 時期 精霊 schrieb:
>> How can I trigger the deletion of the large object when the row
>> containing the oid is deleted?
>>
>> I mean I know that:
>> DELETE FROM pg_largeobject WHERE loid = nnn
>>
>> But is there in jdbc, an automatic way to handle that?
> There is a vacuumlo program in the contrib directory of the
> database source.
Also see contrib/lo for a trigger you can install to delete blobs
immediately when the reference is deleted.
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2005-07-05 14:31 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-07-01 16:05 Streaming blob to db 時期 精霊 <kuon@goyman.com>
2005-07-02 08:00 ` Jesper Thorhauge <jth@conzentrate.com>
2005-07-04 09:33 ` Kris Jurka <books@ejurka.com>
2005-07-05 10:23 ` 時期 精霊 <kuon@goyman.com>
2005-07-05 13:54 ` Roland Walter <rwa@mosaic-ag.com>
2005-07-05 14:31 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox