pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to insert huge string from file to text field via JDBC ?
4+ messages / 3 participants
[nested] [flat]
* How to insert huge string from file to text field via JDBC ?
@ 2013-08-14 09:29 liuyuanyuan <liuyuanyuan@highgo.com.cn>
2013-08-14 13:55 ` Re: How to insert huge string from file to text field via JDBC ? dmp <danap@ttc-cmc.net>
0 siblings, 1 reply; 4+ messages in thread
From: liuyuanyuan @ 2013-08-14 09:29 UTC (permalink / raw)
To: pgsql-jdbc
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!
Yours,
Liu Yuanyuan
August 14,2013
--------------
刘媛媛
山东瀚高基础软件股份有限公司
研发中心
QQ:73129616
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to insert huge string from file to text field via JDBC ?
2013-08-14 09:29 How to insert huge string from file to text field via JDBC ? liuyuanyuan <liuyuanyuan@highgo.com.cn>
@ 2013-08-14 13:55 ` dmp <danap@ttc-cmc.net>
2013-08-14 16:20 ` Re: How to insert huge string from file to text field via JDBC ? David Johnston <polobo@yahoo.com>
0 siblings, 1 reply; 4+ messages in thread
From: dmp @ 2013-08-14 13:55 UTC (permalink / raw)
To: liuyuanyuan <liuyuanyuan@highgo.com.cn>; pgsql-jdbc
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!
>
> Yours,
> Liu Yuanyuan
> August 14,2013
> --------------
> 刘媛媛
> 山东瀚高基础软件股份有限公司
> 研发中心
> QQ:73129616
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to insert huge string from file to text field via JDBC ?
2013-08-14 09:29 How to insert huge string from file to text field via JDBC ? liuyuanyuan <liuyuanyuan@highgo.com.cn>
2013-08-14 13:55 ` Re: How to insert huge string from file to text field via JDBC ? dmp <danap@ttc-cmc.net>
@ 2013-08-14 16:20 ` David Johnston <polobo@yahoo.com>
0 siblings, 0 replies; 4+ messages in thread
From: David Johnston @ 2013-08-14 16:20 UTC (permalink / raw)
To: pgsql-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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to insert huge string from file to text field via JDBC ?
@ 2013-08-15 09:10 liuyuanyuan <liuyuanyuan@highgo.com.cn>
0 siblings, 0 replies; 4+ messages in thread
From: liuyuanyuan @ 2013-08-15 09:10 UTC (permalink / raw)
To: dmp <danap@ttc-cmc.net>; polobo <polobo@yahoo.com>; +Cc: pgsql-jdbc
Thanks of all !
Yes, this is unusual. But since a text field could store
up to 2GB , then I think there must be a way to insert values up to 2G
in JDBC. I know about Large Object and bytea, and I just test text
datatype and want to get a exact result about whether we can insert
long string from huge file into text field or whst's the maximum size.
Hope to get more ideas from you.
Best Regards!
Yours,
Liu Yuanyuan
danap 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.
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!
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2013-08-15 09:10 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-08-14 09:29 How to insert huge string from file to text field via JDBC ? liuyuanyuan <liuyuanyuan@highgo.com.cn>
2013-08-14 13:55 ` dmp <danap@ttc-cmc.net>
2013-08-14 16:20 ` David Johnston <polobo@yahoo.com>
2013-08-15 09:10 Re: How to insert huge string from file to text field via JDBC ? liuyuanyuan <liuyuanyuan@highgo.com.cn>
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