Re: Calling Connection.close() in Connection.finalize()

Поиск
Список
Период
Сортировка
От Barry Lind
Тема Re: Calling Connection.close() in Connection.finalize()
Дата
Msg-id 3D5BE827.9080108@xythos.com
обсуждение исходный текст
Ответ на Calling Connection.close() in Connection.finalize()  (Matthias Brunner <mb@blumenstrasse.vol.at>)
Ответы Re: Calling Connection.close() in Connection.finalize()
Список pgsql-jdbc
Matthias,

That is the behavior I would expect.  If you don't close the connection
you will see this.  The reason here is the JVM doesn't run finalization
when it is exiting.  So you didn't close the connection and the finalize
method is never called because you are just exiting before garbage
collection runs.

--Barry



Matthias Brunner wrote:

>On Thursday 15 August 2002 18:50, Barry Lind wrote:
>
>
>>This is implemented and has been since 7.1.
>>
>>
>>
>
>I'm sorry to be such a pain in the neck :-) Created a test class now (file
>attached).
>
>$md5sum pgjdbc2.jar
>f4ed2deaa88e16e79ccfa1c5b1f5ca22  pgjdbc2.jar
>$export CLASSPATH=pgjdbc2.jar:.
>$javac PgTest.java
>$java PgTest
>
>Message in /var/log/postgresql:
>DEBUG:  connection: host=127.0.0.1 user=mb database=mb
>DEBUG:  pq_recvbuf: unexpected EOF on client connection
>
>When I call Connection.close() explicitly the second message does not appear.
>
>Versions:
>postgresql 7.2,
>JDBC driver for 7.2
>Sun JDK 1.4 (build 1.4.0_01-b03)
>Linux 2.4.18
>
>
>------------------------------------------------------------------------
>
>import java.sql.Connection;
>import java.sql.DriverManager;
>
>public class PgTest {
>
>
>public static void main(String[] args) {
>
>    try {
>        Class.forName("org.postgresql.Driver").newInstance();
>        Connection con = DriverManager.getConnection(
>            "jdbc:postgresql:mb?user=mb");
>
>        //con.close();
>
>    }
>    catch (Exception e) {
>    e.printStackTrace();
>    }
>}
>
>}
>
>



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

Предыдущее
От: Matthias Brunner
Дата:
Сообщение: Re: Calling Connection.close() in Connection.finalize()
Следующее
От: Felipe Schnack
Дата:
Сообщение: datasource