spring - JDBC lost connection while iterating ResultSet -
spring - JDBC lost connection while iterating ResultSet -
in application connect mssql database via tcp/ip using spring , jdbcdaosupport. works fine when connection stable, when unplug ethernet cable while iterating through result set application suspends. doesn't throw exceptions.
jdbctemplate jdbc = getjdbctemplate(); homecoming jdbc.query(sql, mapper, someargs);
where mapper own rowmapper class. have tried using connection , preparedstatement , doesn't solve problem. have solution or have similar problems?
the application hangs, because tcp/ip designed bad connections in mind. when packet doesn't reach destination, sender retries exponential back-off. if behavior not desirable, configure socket blocking timeout (so_timeout).
unfortunately, sql server jdbc driver not have alternative configure socket timeout, block indefinitely.
as nathan hughes indicates in comment, jtds driver have alternative configure sockettimeout, seek driver instead.
spring jdbc resultset jdbctemplate
Comments
Post a Comment