Connection lost

From: Hernan Danielan <hernandanielan(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Connection lost
Date: 2010-05-18 19:18:48
Message-ID: AANLkTinOocrvTmP44mJXOWR6Qdc5-E4JiqcHwLuQqnI2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello! I am using postgress 8.4. I am trying to save to my DB a Large Binary
Object, in localhost, let's say 1.4MB. I read that LargeObjectAPI should be
used.
I have a problem that sometimes i can store the file and some others i get
an exception of

>>org.postgresql.util.PSQLException: An I/O error occured while sending to
the backend.
>>java.net.SocketException: Socket closed

I try to create a connection for each object but the errors persist with big
files. For smaller files like 13KB this example works great and several in
simultaneous. Does anybody have this problem??? I debug the applcation and I
am getting the socket close exception during obj.write (....) here is a bit
of the code

mDbConnector.setAutoCommit(false);
// Get the Large Object Manager to perform operations with
LargeObjectManager lobj =
((org.postgresql.PGConnection)mDbConnector).getLargeObjectAPI();

// Create a new large object
int oid = lobj.create(LargeObjectManager.READ | LargeObjectManager.WRITE);

// Open the large object for writing
LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);
byte []data = cont.getData();

obj.write(data,0,data.length);
obj.close();
PreparedStatement statement = mDbConnector.prepareStatement("INSERT INTO
publicitiescontent (IdPublicities,MimeType,FileName,Title,Data) VALUES
(?,?,?,?,?)");
statement.setBigDecimal(1, new BigDecimal(publicityId));
statement.setString(2, cont.getMimeType());
statement.setString(3, cont.getFileName());
statement.setString(4, cont.getNombre());
statement.setInt(5, oid);
statement.execute();
statement.close();
mDbConnector.commit();

Thanks in advance,
Hernan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andre Lopes 2010-05-18 22:14:04 How to return an Int4 when subtracting dates/timestamps
Previous Message David W Noon 2010-05-18 17:28:45 Re: use of IN() with literals