From: | "Peter V(dot) Cooper" <pvcooper(at)gte(dot)net> |
---|---|
To: | "Michal Josifek" <michal(dot)josifek(at)shoppinggate(dot)cz>, <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: problem with storing BLOBs larger then 2MB |
Date: | 2002-02-13 15:57:15 |
Message-ID: | 5.1.0.14.0.20020213075227.03b01008@mail.gte.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Might be a JVM error. There are usually flags to control how
much stack and heap is avail to the JVM. I have set these
on Sun JVM before to higher than default values.
At 02:19 PM 2/13/2002 +0100, Michal Josifek wrote:
>Hello,
>I have this problem. I need to store some files into my DB and there is (I
>mean) a problem with last (from jdbc.postgresql.org) stable jdbc driver
>(stable driver for pgsql 7.2, java2). When I try to store file larger than
>2MB (2 132 220), exception
>
>java.lang.OutOfMemoryError
> <<no stack trace available>>
>Exception in thread "main"
>
>occured on line "executeUpdate()".
>
>
>Thanks for help
>
>Michal Josifek
>
>
>
>
>Client computer:
>JDBC driver: last stable from jdbc.postgresql.org
>OS: w2k
>JDK: Sun 1.3.1_01
>
>Server computer:
>DB: stable 7.2
>OS: Linux RH 7.2
>
>
>
>
>
>Table SQL:
>
>CREATE TABLE "files" (
>"id" int4 DEFAULT nextval('"files_id_seq"'::text) NOT NULL,
>"name" varchar(250),
>"size" int4,
>"file" bytea,
>"note" varchar(50),
>CONSTRAINT "files_pkey" PRIMARY KEY ("id")
>) WITHOUT OIDS;
>
>
>
>
>
>
>Sample code:
>
>/*
> * db_test.java
> *
> */
>
>package tests;
>
>/**
> *
> * @author Michal
> * @version
> */
>
>import java.util.*;
>import java.util.zip.*;
>import java.sql.*;
>import java.io.*;
>
>public class db_test {
> private Connection conn;
>
> /** Creates new db_test */
> public db_test() {
> }
>
>
> public void writeFile(String strFileName,String strNote) throws
> java.lang.Exception {
>
> File fil = new File(strFileName);
> FileInputStream fis = new FileInputStream(fil);
> System.out.println(fil.length());
> PreparedStatement ps;
>
> ps = this.conn.prepareStatement("insert into files
> (name,size,file,note) values(?, ?, ?, ?)");
> ps.setString(1,fil.getName());
> ps.setInt(2,(int)fil.length());
> ps.setBinaryStream(3,fis,(int)fil.length());
> ps.setString(4,strNote);
>
> ps.executeUpdate(); // EXCEPTION LINE !!!!!
> ps.close();
> fis.close();
> this.conn.commit();
> }
>
> /**
> * @param args the command line arguments
> */
> public static void main (String args[]) throws java.lang.Exception {
> Class.forName("org.postgresql.Driver");
>
> db_test dbts = new db_test();
>
> dbts.conn =
> DriverManager.getConnection("jdbc:postgresql://192.168.30.190:5432/postgres","user","pass");
> dbts.conn.setAutoCommit(false);
>
> dbts.writeFile("d:/java/openssl.tar.gz","Note");
>
> dbts.conn.close();
>
>
> }
>
>}
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-02-13 16:26:58 | Re: pl/pgsql array return |
Previous Message | Dave Cramer | 2002-02-13 14:44:40 | Re: pl/pgsql array return |