Re: bytea size limit?

Поиск
Список
Период
Сортировка
От Michael Privat
Тема Re: bytea size limit?
Дата
Msg-id 1735399359.20040411214842@ceci.mit.edu
обсуждение исходный текст
Ответ на Re: bytea size limit?  (Dave Cramer <pg@fastcrypt.com>)
Ответы Re: bytea size limit?  (Dave Cramer <pg@fastcrypt.com>)
Список pgsql-jdbc
Here's the full code sample for a minimalistic reproduction of the
error. When you run it, if you increase the size (through the command
line argument, you get an out of memory error. On my machine, after
the size gets higher than about 1400000 bytes. I can make it happen every
time.

The DB table has two fields:

id: integer
data: bytea


import java.sql.*;
import java.io.*;
import java.util.*;

public class BlobTest {
        public static void main(String[] args) {
                Connection c = null;
                try {
                        Class.forName("org.postgresql.Driver");
                        String url = "jdbc:postgresql://myserver/mydb";
                        c = DriverManager.getConnection(url, "myuser",
                        "mypass");

                        String sql = "INSERT INTO blobtest (id, data)
                        VALUES(?,?)";

                        int size = Integer.parseInt(args[0]);

                        byte[] data = new byte[size];

                        int id = Math.abs(new Random().nextInt());

                        PreparedStatement stmt = c.prepareStatement(sql);
                        stmt.setInt(1, id);
                        stmt.setBinaryStream(2, new ByteArrayInputStream(data), data.length);

                        stmt.executeUpdate();

                        stmt.close();
                }
                catch(Throwable t) {
                        t.printStackTrace();
                }
                finally {
                        try { c.close(); } catch(Exception e) {}
                }
        }
}



Sunday, April 11, 2004, 9:42:16 PM, you wrote:

DC> No, there is no size limit. However you may have better luck with
DC> largeobjects.
DC> Dave
DC> On Sun, 2004-04-11 at 10:57, Michael Privat wrote:
>> Hi. I have Java code that stores binary into the DB. When I use MS SQL
>> Server 2000 (type image) it works fine. But when I use Postgres 7.4 it
>> fails. Is there a size limit setting somewhere I need to set up?
>>
>> Thanks,
>> Michael
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>>


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: bytea size limit?
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: bytea size limit?