Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VQfEt-0000Fh-66 for pgsql-jdbc@arkaria.postgresql.org; Mon, 30 Sep 2013 15:18:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VQfEs-0008FG-DY for pgsql-jdbc@arkaria.postgresql.org; Mon, 30 Sep 2013 15:18:22 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VQfEr-0008F9-7U for pgsql-jdbc@postgresql.org; Mon, 30 Sep 2013 15:18:21 +0000 Received: from mail-wg0-x22a.google.com ([2a00:1450:400c:c00::22a]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VQfEn-00032V-Lm for pgsql-jdbc@postgresql.org; Mon, 30 Sep 2013 15:18:20 +0000 Received: by mail-wg0-f42.google.com with SMTP id m15so3655061wgh.1 for ; Mon, 30 Sep 2013 08:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-transfer-encoding:content-type; bh=F2mdpgxZkFXp3/tepdKrUlmwLvLww5+ueIqKig1wS9Q=; b=nni1nbE8y56Db0dei4mCEJLSeDWr/x3LWDg+GJP9o7uzqmi17FCdPH8GM0UusNntcO 5/1xAiFGf7uRbtx2kHs1jX6YxqrgEbhxs+Hgs0KyanIKSzm+HZ1si6iy73mrJQZteti1 PhbF7vqBHYHG994HpXt9Gnf0CPBPe+H/vllxLiAD+ibxR1bx0JAj7bJ67Obj+uOGX8cB B65EoBNsSPXOC7C9DTFxLHJm6OKqlpHHkp3EtV0NWA/OWMa/NNcHgo2HMGbnmIXvqyDM YGeULM6bVfBHGKi344TjNXtqEltOmpKASUxdlTvhPNGjuVQjEBW4VnPfEpyEQIbX8YhJ wbrQ== X-Received: by 10.180.182.68 with SMTP id ec4mr14300836wic.40.1380554296522; Mon, 30 Sep 2013 08:18:16 -0700 (PDT) Received: from marco.localnet ([2a01:e34:ee46:c410:beae:c5ff:fe04:b88e]) by mx.google.com with ESMTPSA id fb9sm1943588wid.7.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Sep 2013 08:18:15 -0700 (PDT) From: Marc Cousin To: pgsql-jdbc@postgresql.org Subject: problem with LargeObject and commit Date: Mon, 30 Sep 2013 17:18:13 +0200 Message-ID: <4745149.zA9zVFDa06@marco> User-Agent: KMail/4.11.1 (Linux/3.11.2-1-ARCH; KDE/4.11.1; x86_64; ; ) MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Pg-Spam-Score: 0.7 (/) 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 Hi, I'm having the following problem: I need to stream a LOB to a web client, without consuming a lot of memory. So I am returning getInputStream() to the caller. This works perfectly, except that I have to keep a transaction open to return the large object stream, and I have (or found) no way of closing the transaction when the filestream is closed. So of course, if I did that, I would get a lot of IDLE in transaction sessions... So the logical way seemed to me to extend LargeObjectManager and LargeObject to have a close method on my LargeObject that closes the transaction, meaning that my LargeObject should have a connection attribute. So I wanted to do something like this (not working, it's just for the sake of explanation): public class StreamLargeObjectManager extends LargeObjectManager{ public StreamLargeObject openStreamLargeObject(long oid, int mode) throws SQLException { LargeObject lo = super.open(oid, mode); StreamLargeObject so = new StreamLargeObject(lo, super.getConn()); //cannot be done because no access to connection return so; } } and public class StreamLargeObject extends org.postgresql.largeobject.LargeObject{ Connection conn; LargeObject lobj; public StreamLargeObject(LargeObject lg, BaseConnection conn) throws SQLException { this.lobj = lg; this.conn = conn; } @Override public void close() throws SQLException { lobj.close(); this.conn.commit(); } public getInputStream() throws SQLException { return lobj.getInputStream(); } } As the comment says it all, I cannot do this: conn is private in LargeObjectManager. For now, the problem has been worked around by duplicating all the LargeObjectManager code, but this is obviously ugly and not maintainable. So my question is: have I missed some obvious solution ? Could a getter be added to the LargeObjectManager's connection ? Regards, Marc -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc