Re: BUG #5127: AbstractJdbc2Connection#doRollback should throws Exception if connection is closed
От
takiguchi
Тема
Re: BUG #5127: AbstractJdbc2Connection#doRollback should
throws Exception if connection is closed
Дата
Msg-id
af47b26b0910201129u77876c72jd17a727b45d1b0e8@mail.gmail.com
Ответ на
Re: BUG #5127: AbstractJdbc2Connection#doRollback
should throws Exception if connection is closed (Kevin Grittner)
Список
Дерево обсуждения
Re: BUG #5127: AbstractJdbc2Connection#doRollback
should throws Exception if connection is closed "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Re: BUG #5127: AbstractJdbc2Connection#doRollback should
throws Exception if connection is closed takiguchi <taktos@gmail.com>
Re: BUG #5127: AbstractJdbc2Connection#doRollback
should throws Exception if connection is closed "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Re: BUG #5127: AbstractJdbc2Connection#doRollback
should throws Exception if connection is closed "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
Re: BUG #5127: AbstractJdbc2Connection#doRollback should throws
Exception if connection is closed taktos <taktos@gmail.com>
Hi, Kevin.
Thank you for your reply.
This is a problem of connection pooling, not of transaction.
public void testConnection() {
Connection con = dataSource.getConnection(); // get a connection
from pool (If DB server restarted, invalid connection will be
returned)
boolean valid = true;
try {
// execute some DMLs...
con.commit();
} catch (SQLException e) {
try {
con.rollback();
} catch (SQLException e) {
valid = false; // UNREACHABLE
}
} finally {
if (valid) {
con.close(); // Connection#close() doesn't close
connection in reality in connection pooling mechanism. It simply
returns the connection to pool.
}
}
}
Because rollback() throws no exception when physical connection has
been closed, I cannot know whether rollback was successfully
completed.
In general, if rollback() throws NO exception, it must be a success.
(Success means rollback process is executed, and ended successfully.
This represents that connection could access to server.)
I think if physical connection has closed, Connection's method should
fail and throws Exception.
Other JDBC Drivers (like Oracle) throws Exception when Connection's
method (rollback, prepareStatement, etc.) was called and physical
connection had been closed.
Sincerely,
takiguchiВ списке pgsql-bugs по дате отправления