Re: JDBC Driver Class: Connection Method: isClosed() error
От | Peter T Mount |
---|---|
Тема | Re: JDBC Driver Class: Connection Method: isClosed() error |
Дата | |
Msg-id | 988379595.3ae979cb850be@webmail.retep.org.uk обсуждение исходный текст |
Ответ на | JDBC Driver Class: Connection Method: isClosed() error ("Oscar FRANCOIS" <ofrancois@e-contact.fr>) |
Список | pgsql-bugs |
Quoting Oscar FRANCOIS <ofrancois@e-contact.fr>: > Hi, > > Here are the maximum information about the error: > > OS where the class is running: winnt4 with jdk1.3 > DB OS: Linux Debian potatoe > Postgresql version: 7.0.3 > Driver JDBC: included in the source code. > > Description: > ----------- > First case (postmaster is running ok): > I get the connection with: > conn = DriverManager.getConnection("... > I do a sleep for 5 seconds > I test the code with the isClosed() function. > I do a request like "select * from ...." > Finally I close the connection. > > But If I do the following: > I get the connection with: > conn = DriverManager.getConnection("... > I do a sleep for 5 seconds > (during while I stop the postmaster) > I test the code with the isClosed() function. > ---> WHICH RETURN FALSE!!! <----- > I do a request like "select * from ...." > ---> which generate a SQLException Error <--- > Finally I close the connection. > ---> which generate a SQLException Error <--- > > Why the Hell, does the method isclosed() is answering that everything > is Ok whereas the postmaster > is closed & the next request generate an Error. First check: http://jdbc.postgresql.org/clarify/Connection.html#isClosed This describes how isClosed() is supposed to work as per the JDBC Specifications. In it, you'll notice that before closed() is called, the result of isClosed() is undetermined. Strange but true. So technically you can't call isClosed() before close(). Prior to 7.1, isClosed() simply returned true if it had a PG_Stream object, hence you got true even though the actual connection wasn't there. As of PostgreSQL 7.1, isClosed() sort of goes against the specs, and does the correct thing by returning true only if the connection is valid (does this by first checking to see if it has a connection (as before), then by sending a dummy query to the backend). Goes against the specs, but one of those that makes more sense without really breaking things. Peter -- Peter Mount peter@retep.org.uk PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/ RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/
В списке pgsql-bugs по дате отправления: