아래 메소드가있는 DAO 클래스가 있습니다. 나는 이것을 트랜잭션 관리자 내부에서 호출한다. "conn.commit()"줄을 사용하지 않고 실행했을 때 - 타임 아웃 예외가 발생하지만 이걸로 실행하면 괜찮습니다. 뭐가 문제 야? db를 수정하지 않으면 커밋 할 필요가 없다는 것을 알고 있습니다. commit()
전화로보고커밋없이 connection throw timeoutException이 발생했습니다.
@Override
public List<String> getLinks(int id) throws SQLException {
List<String> list = new ArrayList<>();
Connection conn = factory.newConnection();
Statement statement = null;
ResultSet rs = null;
try {
String expression = "select link from users.links where id=" + id + " order by id_link desc";
statement = conn.createStatement();
rs = statement.executeQuery(expression);
while (rs.next()) {
list.add(rs.getString("link"));
}
// !!!!!!!!!!!!! without next line method throw TimeoutException
conn.commit(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
return list;
} catch (SQLException e) {
rollBackQuietly(conn);
e.printStackTrace();
} finally {
closeQuaitly(rs);
closeQuaitly(statement);
closeQuaitly(conn);
}
return null;
}
여기서 TimeoutException이 발생합니까? – jtahlborn
"rs = statement.executeQuery (expession)"줄이 나옵니다. – Paul