@Override public void setCatalog(String catalog) throws SQLException { try { tajoClient.selectDatabase(catalog); } catch (TajoException e) { throw SQLExceptionUtil.toSQLException(e); } }
public static SQLException makeUnableToEstablishConnection(Throwable t) { return makeSQLException( ResultCode.CLIENT_UNABLE_TO_ESTABLISH_CONNECTION, t.getMessage()); } }
public TajoSQLException(Errors.ResultCode code, Throwable t, String...args) { super(ErrorMessages.getMessage(code, args), SQLExceptionUtil.toSQLState(code), t); } }
private Schema waitOnResult() throws SQLException { try { QueryStatus status = TajoClientUtil.waitCompletion(tajoClient, queryId); if (status.getState() != TajoProtos.QueryState.QUERY_SUCCEEDED) { throw new SQLException(status.getErrorMessage(), SQLExceptionUtil.toSQLState(ResultCode.INTERNAL_ERROR), ResultCode.INTERNAL_ERROR.getNumber()); } ClientProtos.GetQueryResultResponse response = tajoClient.getResultResponse(queryId); TableDesc tableDesc = new TableDesc(response.getTableDesc()); return tableDesc.getLogicalSchema(); } catch (TajoException e) { throw SQLExceptionUtil.toSQLException(e); } } }
protected ResultSet executeSQL(String sql) throws SQLException { ClientProtos.SubmitQueryResponse response = tajoClient.executeQuery(sql); SQLExceptionUtil.throwIfError(response.getState()); QueryId queryId = new QueryId(response.getQueryId()); switch (response.getResultType()) { case ENCLOSED: return TajoClientUtil.createResultSet(tajoClient, response, fetchSize); case FETCH: WaitingResultSet result = new WaitingResultSet(tajoClient, queryId, fetchSize); if (blockWait) { result.getSchema(); } return result; default: return TajoClientUtil.createNullResultSet(queryId); } }
private Schema waitOnResult() throws SQLException { try { QueryStatus status = TajoClientUtil.waitCompletion(tajoClient, queryId); if (status.getState() != TajoProtos.QueryState.QUERY_SUCCEEDED) { throw new SQLException(status.getErrorMessage(), SQLExceptionUtil.toSQLState(ResultCode.INTERNAL_ERROR), ResultCode.INTERNAL_ERROR.getNumber()); } ClientProtos.GetQueryResultResponse response = tajoClient.getResultResponse(queryId); TableDesc tableDesc = new TableDesc(response.getTableDesc()); return tableDesc.getLogicalSchema(); } catch (TajoException e) { throw SQLExceptionUtil.toSQLException(e); } } }
protected ResultSet executeSQL(String sql) throws SQLException { ClientProtos.SubmitQueryResponse response = tajoClient.executeQuery(sql); SQLExceptionUtil.throwIfError(response.getState()); QueryId queryId = new QueryId(response.getQueryId()); switch (response.getResultType()) { case ENCLOSED: return TajoClientUtil.createResultSet(tajoClient, response, fetchSize); case FETCH: WaitingResultSet result = new WaitingResultSet(tajoClient, queryId, fetchSize); if (blockWait) { result.getSchema(); } return result; default: return TajoClientUtil.createNullResultSet(queryId); } }
@Override public void setCatalog(String catalog) throws SQLException { try { tajoClient.selectDatabase(catalog); } catch (TajoException e) { throw SQLExceptionUtil.toSQLException(e); } }
public TajoSQLException(Errors.ResultCode code, Throwable t, String...args) { super(ErrorMessages.getMessage(code, args), SQLExceptionUtil.toSQLState(code), t); } }
public static SQLException makeUnableToEstablishConnection(Throwable t) { return makeSQLException( ResultCode.CLIENT_UNABLE_TO_ESTABLISH_CONNECTION, t.getMessage()); } }
public static void throwIfError(ReturnState state) throws SQLException { if (isError(state)) { throw toSQLException(state); } }
public TajoSQLException(Errors.ResultCode code, String...args) { super(ErrorMessages.getMessage(code, args), SQLExceptionUtil.toSQLState(code)); }
public static void throwIfError(ReturnState state) throws SQLException { if (isError(state)) { throw toSQLException(state); } }
public TajoSQLException(Errors.ResultCode code, String...args) { super(ErrorMessages.getMessage(code, args), SQLExceptionUtil.toSQLState(code)); }
@Override public boolean isValid(int timeout) throws SQLException { try { if (tajoClient.isConnected()) { ResultSet resultSet = tajoClient.executeQueryAndGetResult("SELECT 1;"); boolean next = resultSet.next(); boolean valid = next && resultSet.getLong(1) == 1; resultSet.close(); return valid; } else { return false; } } catch (TajoException e) { throw SQLExceptionUtil.toSQLException(e); } }
public TajoSQLException(PrimitiveProtos.ReturnState returnState) { super(returnState.getMessage(), SQLExceptionUtil.toSQLState(returnState.getReturnCode()), ExceptionUtil.toTajoException(returnState)); }
@Override public boolean isValid(int timeout) throws SQLException { try { if (tajoClient.isConnected()) { ResultSet resultSet = tajoClient.executeQueryAndGetResult("SELECT 1;"); boolean next = resultSet.next(); boolean valid = next && resultSet.getLong(1) == 1; resultSet.close(); return valid; } else { return false; } } catch (TajoException e) { throw SQLExceptionUtil.toSQLException(e); } }
public TajoSQLException(PrimitiveProtos.ReturnState returnState) { super(returnState.getMessage(), SQLExceptionUtil.toSQLState(returnState.getReturnCode()), ExceptionUtil.toTajoException(returnState)); }
public static SQLException toSQLException(DefaultTajoException e) throws SQLException { if (e instanceof TajoRuntimeException) { return toSQLException(e.getErrorCode(), ((TajoRuntimeException) e).getCause().getMessage()); } else { return toSQLException(e.getErrorCode(), e.getMessage()); } }
public static SQLException toSQLException(DefaultTajoException e) throws SQLException { if (e instanceof TajoRuntimeException) { return toSQLException(e.getErrorCode(), ((TajoRuntimeException) e).getCause().getMessage()); } else { return toSQLException(e.getErrorCode(), e.getMessage()); } }