@Override public String getSchema() throws SQLException { checkOpen(); try { UserProtos.GetServerMetaResp response = client.getServerMeta().get(); if (response.getStatus() != UserProtos.RequestStatus.OK) { UserBitShared.DrillPBError drillError = response.getError(); throw new SQLException("Error when getting server meta: " + drillError.getMessage()); } UserProtos.ServerMeta serverMeta = response.getServerMeta(); String currentSchema = serverMeta.hasCurrentSchema() ? serverMeta.getCurrentSchema() : null; return StringUtils.isEmpty(currentSchema) ? null : currentSchema; } catch (InterruptedException | ExecutionException e) { throw new SQLException("Error when getting server meta", e); } }
private ServerMeta getServerMeta() throws SQLException { assert getServerMetaSupported(); if (serverMeta == null) { synchronized(this) { if (serverMeta == null) { DrillConnectionImpl connection = (DrillConnectionImpl) getConnection(); try { GetServerMetaResp resp = connection.getClient().getServerMeta().get(); if (resp.getStatus() != RequestStatus.OK) { DrillPBError drillError = resp.getError(); throw new SQLException("Error when getting server meta: " + drillError.getMessage()); } serverMeta = resp.getServerMeta(); convertSupport = SQLConvertSupport.toSQLConvertSupport(serverMeta.getConvertSupportList()); } catch (InterruptedException e) { throw new SQLException("Interrupted when getting server meta", e); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause == null) { throw new AssertionError("Something unknown happened", e); } Throwables.throwIfUnchecked(cause); throw new SQLException("Error when getting server meta", cause); } } } } return serverMeta; }
private ServerMeta getServerMeta() throws SQLException { assert getServerMetaSupported(); if (serverMeta == null) { synchronized(this) { if (serverMeta == null) { DrillConnectionImpl connection = (DrillConnectionImpl) getConnection(); try { GetServerMetaResp resp = connection.getClient().getServerMeta().get(); if (resp.getStatus() != RequestStatus.OK) { DrillPBError drillError = resp.getError(); throw new SQLException("Error when getting server meta: " + drillError.getMessage()); } serverMeta = resp.getServerMeta(); convertSupport = SQLConvertSupport.toSQLConvertSupport(serverMeta.getConvertSupportList()); } catch (InterruptedException e) { throw new SQLException("Interrupted when getting server meta", e); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause == null) { throw new AssertionError("Something unknown happened", e); } Throwables.throwIfUnchecked(cause); throw new SQLException("Error when getting server meta", cause); } } } } return serverMeta; }