From: David Johnston <polobo@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: How to insert huge string from file to text field via JDBC ?
Date: Wed, 14 Aug 2013 09:20:03 -0700 (PDT)
Message-ID: <1376497203370-5767425.post@n5.nabble.com> (raw)
In-Reply-To: <520B8C5B.5000501@ttc-cmc.net>
References: <2013081417294966226913@highgo.com.cn>
<520B8C5B.5000501@ttc-cmc.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
While in theory this could work I would not recommend it. If you try you'd
want to make sure your memory settings (and actual memory) can handle that
much data.
The first question to ask yourself (and tell others) is WHY you want to do
this. For a document this large you should first consider storing the data
outside of the database and simply putting a "pointer" to said file in the
database.
A second option would be to compress the text file and use the "large object
api" to manipulate the data (or simply a bytea if the compressed data is
small enough).
I do not handle anything near that size so actual technical help I can
provide is limited. For me I store text or bytea documents using the simple
"setObject/setString" methods and make sure my head memory allocation and
other memory settings are sufficiently large for processing the data through
Java.
Dave
dmp-2 wrote
> I have not tried with that size of document, but using a standard
> InputReader seems to work fine. Just setup a FileReader, buffer
> into a StringBuffer then when finished use the stringBuffer.toString()
> in the preparedStatement.
>
> danap.
>
>
> liuyuanyuan wrote:
>> Hi,
>> Now I need to insert a huge string from a huge file (e.g. a 1 GB
>> text document) to a TEXT type field.
>> But I don't know any other way to insert string except setString()
>> for preparedStatement.
>> Anyone know about this, please write to me. Thanks in advance!
>>
>> Best Wish!
>>
--
View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-insert-huge-string-from-file-to-text-field-via-JDBC-t...
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: polobo@yahoo.com
Subject: Re: How to insert huge string from file to text field via JDBC ?
In-Reply-To: <1376497203370-5767425.post@n5.nabble.com>
References: <2013081417294966226913@highgo.com.cn> <520B8C5B.5000501@ttc-cmc.net> <1376497203370-5767425.post@n5.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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