PGCopyOutputStream Doesn't Hold Connection

From: Michael Daines <ax2groin(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: PGCopyOutputStream Doesn't Hold Connection
Date: 2012-10-17 20:46:07
Message-ID: 461eb8dc-0a13-42c1-a84e-8a6545b0c58d@googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Something that might be worth noting (in documentation?) is that the PGCopyOutputStream class doesn't hold a reference to its Connection.

We came across this because we were trying to keep our DB code separate from the logic, and we started getting errors writing to the PGCopyOutputStream. We banged our heads against it for a while before realizing that the Connection was getting garbage collected while we were still writing to it.

Our solution was to extend PGCopyOutputStream and hold on to the Connection in that child class, also giving it responsibility for closing it.

I'm not sure I would call this a defect, but it is something I wanted to share with other people, since we couldn't find anything in our searches on the problem while we were having it.

Browse pgsql-jdbc by date

  From Date Subject
Next Message Sérgio Saquetim 2012-10-18 04:16:32 Re: Severe performance degradation when using the 9.2-1000 JDBC 4 driver
Previous Message David Johnston 2012-10-17 18:17:47 Re: Parameters are not being setted in a copy statement