Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9do5-0004W8-2E for pgsql-jdbc@arkaria.postgresql.org; Wed, 14 Aug 2013 16:20:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V9do3-0004mv-PW for pgsql-jdbc@arkaria.postgresql.org; Wed, 14 Aug 2013 16:20:19 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9dnv-0004aw-OB for pgsql-jdbc@postgresql.org; Wed, 14 Aug 2013 16:20:11 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V9dno-0000Oa-NF for pgsql-jdbc@postgresql.org; Wed, 14 Aug 2013 16:20:11 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1V9dnn-0002jj-CN for pgsql-jdbc@postgresql.org; Wed, 14 Aug 2013 09:20:03 -0700 Date: Wed, 14 Aug 2013 09:20:03 -0700 (PDT) From: David Johnston To: pgsql-jdbc@postgresql.org Message-ID: <1376497203370-5767425.post@n5.nabble.com> In-Reply-To: <520B8C5B.5000501@ttc-cmc.net> References: <2013081417294966226913@highgo.com.cn> <520B8C5B.5000501@ttc-cmc.net> Subject: Re: How to insert huge string from file to text field via JDBC ? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 4.5 (++++) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org 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-tp5767394p5767425.html 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