SnappyException resultSetNotFoundException(long cursorId, String op) { SnappyExceptionData exData = new SnappyExceptionData(); exData.setReason("No result set open with ID=" + cursorId + " for operation " + op); exData.setSqlState(SQLState.LANG_RESULT_SET_NOT_OPEN.substring(0, 5)); exData.setErrorCode(ExceptionSeverity.STATEMENT_SEVERITY); return new SnappyException(exData, getServerInfo()); }
SnappyException tokenMismatchException(ByteBuffer token, final String op) { SnappyExceptionData exData = new SnappyExceptionData(); String message = token != null && token.hasRemaining() ? "connection token " + ConnectionHolder.getTokenAsString(token) + " mismatch for operation " + op : "No connection token passed for operation " + op; exData.setReason(MessageService.getTextMessage( SQLState.NET_CONNECT_AUTH_FAILED, message)); exData.setSqlState(SQLState.NET_CONNECT_AUTH_FAILED.substring(0, 5)); exData.setErrorCode(ExceptionSeverity.SESSION_SEVERITY); return new SnappyException(exData, getServerInfo()); }
private SnappyException notImplementedException(String method) { SnappyExceptionData exData = new SnappyExceptionData(); exData.setReason("ASSERT: " + method + "() not implemented"); exData.setSqlState(SQLState.JDBC_METHOD_NOT_SUPPORTED_BY_SERVER); exData.setErrorCode(ExceptionSeverity.STATEMENT_SEVERITY); return new SnappyException(exData, getServerInfo()); }
SnappyException statementNotFoundException(long stmtId, String op, boolean isPrepared) { SnappyExceptionData exData = new SnappyExceptionData(); exData.setReason("No " + (isPrepared ? "prepared " : "") + "statement with ID=" + stmtId + " for operation " + op); exData.setSqlState(SQLState.LANG_DEAD_STATEMENT); exData.setErrorCode(ExceptionSeverity.STATEMENT_SEVERITY); return new SnappyException(exData, getServerInfo()); }
private SnappyException internalException(String message) { SnappyExceptionData exData = new SnappyExceptionData(); exData.setReason(message); exData.setSqlState(SQLState.JAVA_EXCEPTION); exData.setErrorCode(ExceptionSeverity.NO_APPLICABLE_SEVERITY); return new SnappyException(exData, getServerInfo()); }
private SnappyExceptionData snappyWarning(SQLWarning warnings) throws SQLException { SnappyExceptionData warningData = new SnappyExceptionData( warnings.getMessage(), warnings.getErrorCode()) .setSqlState(warnings.getSQLState()); ArrayList<SnappyExceptionData> nextWarnings = null; SQLWarning next = warnings.getNextWarning(); if (next != null) { nextWarnings = new ArrayList<>(); do { nextWarnings.add(new SnappyExceptionData(next.getMessage(), next.getErrorCode()).setSqlState(next.getSQLState())); } while ((next = next.getNextWarning()) != null); } //SnappyExceptionData sqlw = new SnappyExceptionData(warningData); //sqlw.setNextWarnings(nextWarnings); if (nextWarnings != null) { warningData.setReason(warningData.getReason() + nextWarnings.toString()); } return warningData; }
public SnappyException newSnappyException(String messageId, Object... args) { SnappyExceptionData exData = new SnappyExceptionData(); exData.setSqlState(StandardException.getSQLStateFromIdentifier(messageId)); exData.setErrorCode(StandardException.getSeverityFromIdentifier(messageId)); exData.setReason(MessageService.getCompleteMessage(messageId, args)); return new SnappyException(exData, getServerInfo()); }
unsetReason(); } else { setReason((String)value);
/** * Helper method Validate the connection Id. If Id not found in the map throw * the connection unavailable exception. * * @return ConnectionHolder if found in the map. */ private ConnectionHolder getValidConnection(long connId, ByteBuffer token) throws SnappyException { ConnectionHolder connHolder = this.connectionMap.getPrimitive(connId); if (connHolder != null) { if (connHolder.sameToken(token)) { return connHolder; } else { throw tokenMismatchException(token, "getConnection [connId=" + connId + ']'); } } else { SnappyExceptionData exData = new SnappyExceptionData(); exData.setReason("No connection with ID=" + ConnectionHolder.getTokenAsString(token)); exData.setSqlState(SQLState.NO_CURRENT_CONNECTION); exData.setErrorCode(ExceptionSeverity.STATEMENT_SEVERITY); throw new SnappyException(exData, getServerInfo()); } }