QueryTimeout 구성
지정된 시간(초) 이전에 실행이 완료되지 못하면 SQL(Structured Query Language)문이 인터럽트되도록 애플리케이션의 데이터 소스에 조회 제한시간을 구성할 수 있습니다.
시작하기 전에
이 태스크 정보
- webSphereDefaultQueryTimeout은 제한시간이 초과하기 전에 SQL문이 실행할 수 있는 시간(초)인 기본 조회 제한시간을 설정합니다. 이 기본값은 syncQueryTimeoutWithTransactionTimeout 사용자 정의 특성이 사용된 경우 JTA(Java™ Transaction API) 트랜잭션 중에 대체됩니다.
- syncQueryTimeoutWithTransactionTimeout은 SQL문의 기본 조회 제한시간으로 JTA 트랜잭션에 남아 있는(있는 경우) 시간을 사용합니다.
- TM(Transaction Manager) 제한시간 설정을 기반으로 현재 JTA 트랜잭션에 남아 있는 시간 - syncQueryTimeoutWithTransactionTimeout
- 구성에 지정된 절대 시간(초) - webSphereDefaultQueryTimeout
프로시저
결과
예
statement = connection.createStatement();
statement.executeUpdate(sqlcommand1); // query timeout of 20 seconds is used
statement.executeUpdate(sqlcommand2); // query timeout of 20 seconds is used
transaction.setTransactionTimeout(30);
transaction.begin();
try
{
statement.executeUpdate(sqlcommand3); // query timeout of 30 seconds is used
// assume the above operation took 5 seconds, remaining time = 30 - 5 seconds
statement.executeUpdate(sqlcommand4); // query timeout of 25 seconds is used
// assume the above operation took 10 seconds, , remaining time = 25 - 10 seconds
statement.executeUpdate(sqlcommand5); // query timeout of 15 seconds is used
}
finally
{
transaction.commit();
}
statement.executeUpdate(sqlcommand6); // query timeout of 20 seconds is used
다음 예는 데이터 소스 사용자 정의 특성
webSphereDefaultQueryTimeout
= 20 및 syncQueryTimeoutWithTransactionTimeout =
false를 설정한 영향을 설명합니다. webSphereDefaultQueryTimeout만
설정한 경우, JTA 트랜잭션 내에서 실행되는지 여부에 관계 없이 모든 명령문에 기본 제한시간 값이
사용됩니다. statement = connection.createStatement();
statement.executeUpdate(sqlcommand1); // query timeout of 20 seconds is used
statement.executeUpdate(sqlcommand2); // query timeout of 20 seconds is used
transaction.setTransactionTimeout(30);
transaction.begin();
try
{
statement.executeUpdate(sqlcommand3); // query timeout of 20 seconds is used
// assume the above operation took 5 seconds
statement.executeUpdate(sqlcommand4); // query timeout of 20 seconds is used
// assume the above operation took 10 seconds
statement.executeUpdate(sqlcommand5); // query timeout of 20 seconds is used
}
finally
{
transaction.commit();
}
statement.executeUpdate(sqlcommand6); // query timeout of 20 seconds is used
애플리케이션
코드에서 java.sql.Statement.setQueryTimeout
인터페이스를 호출하여 언제든 명령문의 조회 제한시간을
대체할 수 있습니다.