X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 00202D9921 for ; Tue, 27 Sep 2005 12:17:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33825-07 for ; Tue, 27 Sep 2005 15:17:37 +0000 (GMT) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.197]) by svr1.postgresql.org (Postfix) with ESMTP id 95E23D993A for ; Tue, 27 Sep 2005 12:17:36 -0300 (ADT) Received: by xproxy.gmail.com with SMTP id s14so1348405wxc for ; Tue, 27 Sep 2005 08:17:36 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; b=K0c5yGzz53uxp6XQJ1nNt6XZTfXTa0y2wNWXXKA6QSHHkattRVxyBjjuNURAtoo2Glxxl+ZWLG9hl184S0kGNPPK8FKxDJO4E01me1+QVIIY3oWhjZW43era9/JGyVHkohdxu5UGbRROB8bpd7344qqMISEp5xQYwh0W6WBOuR4= Received: by 10.70.14.8 with SMTP id 8mr3032284wxn; Tue, 27 Sep 2005 08:17:36 -0700 (PDT) Received: by 10.70.41.14 with HTTP; Tue, 27 Sep 2005 08:17:36 -0700 (PDT) Message-ID: <89cc056d05092708171371d8dc@mail.gmail.com> Date: Tue, 27 Sep 2005 11:17:36 -0400 From: Alfredo Rico Reply-To: Alfredo Rico To: pgsql-jdbc@postgresql.org Subject: Trouble with PreparedStatement.setBinaryData or setBytes() MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2472_33370439.1127834256051" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.718 required=5 tests=[AWL=0.397, HTML_10_20=0.295, HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200509/114 X-Sequence-Number: 13899 ------=_Part_2472_33370439.1127834256051 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi friends, greetings :-) First of all, please apologize by my bad english, I don't speak yet very well. I speak spanish. I'm working in a Java Web development using NetBeans 4.1 + Jakarta FileUploads + PostgreSQL v7.4.7 The situation is as following: I have a table called 'attachedfiles' in my DB with the follow structre: CREATE TABLE attachedfiles ( namefile character varying(100) NOT NULL, content bytea NOT NULL, id integer NOT NULL ); I have Java class with the following code ( very similar to code founded at http://www.postgresql.org/docs/7.4/static/jdbc-binary-data.html ): InputStream is =3D new FileInputStream("/home/alfredo/PostgresqlBook.pdf"); PreparedStatement ps =3D conn.prepareStatement("INSERT INTO attachedfiles (= id, namefile, contentfile) VALUES (?, ?, ?)"); ps.setInt(1,4); ps.setString(2,"PostgresqlBook.pdf"); ps.setBinaryStream(3, is, is.avalaible() ); ps.executeUpdate(); ps.close(); is.close(); The great and terrible problem is the following: If input file (pdf, doc, png, txt whatever...) exceed 2 MB I have the following exception: javax.servlet.ServletException: La ejecuci=F3n del Servlet lanz=F3 una excepci=F3n org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter( MonitorFilter.java:362) causa ra=EDz java.lang.OutOfMemoryError: Java heap space With the following variations in java code even doesn't work: InputStream is =3D new FileInputStream("/home/alfredo/PostgresqlBook.pdf"); byte data[] =3D new bytes[is.avalaible()]; is.read(data); PreparedStatement ps =3D conn.prepareStatement("INSERT INTO attachedfiles (= id, namefile, contentfile) VALUES (?, ?, ?)"); ps.setInt(1,4); ps.setString(2,"PostgresqlBook.pdf"); ps.setBytes(3, data ); ps.executeUpdate(); ps.close(); is.close(); Besides, I have increased JVM heap starting Netbeans IDE using the followin= g sentence: $ ./netbeans -J-Xmx300m And even don't work... Could any body help me ? I don't know what to do :-( Beforehand thank you very much by your help and support. Kind regards.- Alfredo Rico. ------=_Part_2472_33370439.1127834256051 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi friends, greetings :-)

First of all, please apologize by my bad english, I don't speak yet very we= ll. I speak spanish.

I'm working in a Java Web development using NetBeans 4.1 + Jakarta FileUplo= ads + PostgreSQL v7.4.7

The situation is as following:

I have a table called 'attachedfiles' in my DB with the follow structre:
CREATE TABLE attachedfiles (
    namefile character varying(100) NOT NULL,   &n= bsp;
    content bytea NOT NULL,
    id integer NOT NULL
);

I have Java class with the following code ( very similar to code founded at=
http://www.postgresql.org/docs/7.4/static/jdbc-binary-data.html ):

InputStream is =3D new FileInputStream("/home/alfredo/PostgresqlBook.p= df");
PreparedStatement ps =3D conn.prepareStatement("INSERT INTO attachedfi= les (id, namefile, contentfile) VALUES (?, ?, ?)");
ps.setInt(1,4);
ps.setString(2,"PostgresqlBook.pdf");
ps.setBinaryStream(3, is, is.avalaible() );
ps.executeUpdate();
ps.close();
is.close();


The great and terrible problem is the following:
If input file (pdf, doc, png, txt whatever...) exceed 2 MB
I have the following exception:

javax.servlet.ServletException: La ejecuci=F3n del
Servlet lanz=F3 una excepci=F3n
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilte= r.java:362)
causa ra=EDz
java.lang.OutOfMemoryError: Java heap space

With the following variations in java code even doesn't work:

InputStream is =3D new FileInputStream("/home/alfredo/PostgresqlBook.p= df");
byte data[] =3D new bytes[is.avalaible()];
is.read(data);
PreparedStatement ps =3D conn.prepareStatement("INSERT INTO attachedfi= les (id, namefile, contentfile) VALUES (?, ?, ?)");
ps.setInt(1,4);
ps.setString(2,"PostgresqlBook.pdf");
ps.setBytes(3, data );
ps.executeUpdate();
ps.close();
is.close();


Besides, I have increased JVM heap starting Netbeans IDE using the followin= g sentence:

$ ./netbeans -J-Xmx300m

And even don't work...

Could any body help me ? I don't know what to do :-(

Beforehand thank you very much by your help and support.

Kind regards.-
Alfredo Rico. ------=_Part_2472_33370439.1127834256051--