PGCopyOutputStream Doesn't Hold Connection

Поиск
Список
Период
Сортировка
Искать

PGCopyOutputStream Doesn't Hold Connection

От:
Michael Daines <ax2groin@gmail.com>
Дата:
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.

FAQ