List of usage examples for java.sql SQLTimeoutException SQLTimeoutException
public SQLTimeoutException(Throwable cause)
SQLTimeoutException
object with a given cause
. From source file:org.apache.hive.jdbc.HiveStatement.java
TGetOperationStatusResp waitForOperationToComplete() throws SQLException { TGetOperationStatusReq statusReq = new TGetOperationStatusReq(stmtHandle); boolean shouldGetProgressUpdate = inPlaceUpdateStream != InPlaceUpdateStream.NO_OP; statusReq.setGetProgressUpdate(shouldGetProgressUpdate); if (!shouldGetProgressUpdate) { /**/*from ww w . ja va2 s . co m*/ * progress bar is completed if there is nothing we want to request in the first place. */ inPlaceUpdateStream.getEventNotifier().progressBarCompleted(); } TGetOperationStatusResp statusResp = null; // Poll on the operation status, till the operation is complete while (!isOperationComplete) { try { /** * For an async SQLOperation, GetOperationStatus will use the long polling approach It will * essentially return after the HIVE_SERVER2_LONG_POLLING_TIMEOUT (a server config) expires */ statusResp = client.GetOperationStatus(statusReq); inPlaceUpdateStream.update(statusResp.getProgressUpdateResponse()); Utils.verifySuccessWithInfo(statusResp.getStatus()); if (statusResp.isSetOperationState()) { switch (statusResp.getOperationState()) { case CLOSED_STATE: case FINISHED_STATE: isOperationComplete = true; isLogBeingGenerated = false; break; case CANCELED_STATE: // 01000 -> warning throw new SQLException("Query was cancelled", "01000"); case TIMEDOUT_STATE: throw new SQLTimeoutException("Query timed out after " + queryTimeout + " seconds"); case ERROR_STATE: // Get the error details from the underlying exception throw new SQLException(statusResp.getErrorMessage(), statusResp.getSqlState(), statusResp.getErrorCode()); case UKNOWN_STATE: throw new SQLException("Unknown query", "HY000"); case INITIALIZED_STATE: case PENDING_STATE: case RUNNING_STATE: break; } } } catch (SQLException e) { isLogBeingGenerated = false; throw e; } catch (Exception e) { isLogBeingGenerated = false; throw new SQLException(e.toString(), "08S01", e); } } /* we set progress bar to be completed when hive query execution has completed */ inPlaceUpdateStream.getEventNotifier().progressBarCompleted(); return statusResp; }