jdbc - avoid dead lock