protected void checkOffset(long offset) throws SQLException { if (offset < 0) { throw ThriftExceptionUtil.newSQLException(SQLState.BLOB_BAD_POSITION, null, offset + 1); } else if (offset >= Integer.MAX_VALUE) { throw ThriftExceptionUtil.newSQLException( SQLState.BLOB_POSITION_TOO_LARGE, null, offset + 1); } }
/** * {@inheritDoc} */ @Override public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { throw ThriftExceptionUtil.notImplemented("PreparedStatement.setSQLXML"); }
Exception newExceptionForNodeFailure(HostConnection expectedSource, String op, int isolationLevel, Throwable cause, boolean snappyException) { final HostConnection source = this.currentHostConnection; String opNode = op + " {current node = " + source + '}'; if (isolationLevel == Connection.TRANSACTION_NONE) { // throw X0Z01 for this case String err = expectedSource + (cause instanceof TException ? " {caused by: " + ThriftExceptionUtil.getExceptionString(cause) + '}' : ""); return snappyException ? ThriftExceptionUtil.newSnappyException( SQLState.GFXD_NODE_SHUTDOWN, cause, source != null ? source.hostAddr.toString() : null, err, op) : ThriftExceptionUtil.newSQLException(SQLState.GFXD_NODE_SHUTDOWN, cause, err, opNode); } else { // throw 40XD0 for this case String err = " operation=" + opNode + (cause instanceof TException ? " caused by: " + ThriftExceptionUtil.getExceptionString(cause) : ""); return snappyException ? ThriftExceptionUtil.newSnappyException( SQLState.DATA_CONTAINER_CLOSED, cause, source != null ? source.hostAddr.toString() : null, expectedSource, err) : ThriftExceptionUtil.newSQLException(SQLState.DATA_CONTAINER_CLOSED, cause, expectedSource, err); } }
protected Object getObject(final int columnIndex, final Map<String, Class<?>> map, final int snappyTypeValue, final Row row) throws SQLException { if (map == null) { throw ThriftExceptionUtil.newSQLException(SQLState.INVALID_API_PARAMETER, null, null, "map", "FetchColumnValue.getObject(int,Map)"); } if (map.isEmpty()) { // Map is empty call the normal getObject method. return getObject(columnIndex, snappyTypeValue, row); } else { throw ThriftExceptionUtil .notImplemented("FetchColumnValue.getObject(int,Map)"); } }
public static SQLClientInfoException newSQLClientInfoException( String sqlState, Map<String, ClientInfoStatus> failedProperties, Throwable t, Object... args) { return new SQLClientInfoException(getMessageUtil().getCompleteMessage( sqlState, args), getSQLStateFromIdentifier(sqlState), getSeverityFromIdentifier(sqlState), failedProperties, t); }
private SnappyException failoverExhausted(Set<HostAddress> failedServers, Throwable cause) { final ArrayList<HostAddress> locators = this.locators; return ThriftExceptionUtil.newSnappyException( SQLState.DATA_CONTAINER_CLOSED, cause, failedServers != null ? failedServers.toString() : null, locators.get(0), " {failed after trying all available servers: " + controlHostSet + (locators.size() > 1 ? ", secondary-locators=" + locators.subList( 1, locators.size()) : "") + (cause instanceof TException ? " with: " + ThriftExceptionUtil.getExceptionString(cause) + '}' : "}")); } }
private SnappyException unexpectedError(Throwable t, HostAddress host) { this.controlHost = null; if (this.controlLocator != null) { this.controlLocator.getOutputProtocol().getTransport().close(); this.controlLocator = null; } return ThriftExceptionUtil.newSnappyException(SQLState.JAVA_EXCEPTION, t, host != null ? host.toString() : null, t.getClass(), t.getMessage()); }
if (t instanceof TException) { stack = new StringBuilder("Cause: ").append( ThriftExceptionUtil.getExceptionString(t)).append("; Server STACK: "); } else { stack = new StringBuilder("Server STACK: ");
/** * {@inheritDoc} */ @Override public SQLWarning getWarnings() throws SQLException { if (this.warnings != null) { super.lock(); try { final SnappyExceptionData warnings = this.warnings; if (warnings != null) { return ThriftExceptionUtil.newSQLWarning(warnings, null); } } finally { super.unlock(); } } return null; }
/** * <code>setClientInfo</code> will always throw a * <code>SQLClientInfoException</code> since SnappyData does not support any * properties. */ @Override public void setClientInfo(String name, String value) throws SQLClientInfoException { if (name != null || value != null) { HashMap<String, ClientInfoStatus> failedProperties = new HashMap<>(1); if (name != null) { failedProperties.put(name, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } throw ThriftExceptionUtil.newSQLClientInfoException( SQLState.PROPERTY_UNSUPPORTED_CHANGE, failedProperties, null, name, value); } }
public static SnappyException newSnappyException(String sqlState, Throwable t, String serverInfo, Object... args) { SnappyExceptionData payload = new SnappyExceptionData(getMessageUtil() .getCompleteMessage(sqlState, args), getSeverityFromIdentifier(sqlState)) .setSqlState(getSQLStateFromIdentifier(sqlState)); SnappyException se = new SnappyException(payload, serverInfo); if (t != null) { if (t instanceof SnappyException) { SnappyException next = (SnappyException)t; se.addToNextExceptions(next.getExceptionData()); if (next.getNextExceptions() != null) { se.getNextExceptions().addAll(next.getNextExceptions()); } } se.initCause(t); } return se; }
SnappyException newSnappyExceptionForConnectionClose(HostConnection source, Set<HostAddress> failedServers, boolean createNewConnection, Throwable cause) { // if cause is a node failure exception then return it if (cause instanceof SnappyException) { SnappyException se = (SnappyException)cause; SnappyExceptionData seData = se.getExceptionData(); if (SQLState.GFXD_NODE_SHUTDOWN_PREFIX.equals(seData.getSqlState()) || SQLState.DATA_CONTAINER_CLOSED.equals(seData.getSqlState())) { if (createNewConnection) { tryCreateNewConnection(source, failedServers, cause); } return se; } } return ThriftExceptionUtil.newSnappyException( SQLState.NO_CURRENT_CONNECTION, cause, source != null ? source.hostAddr.toString() : null); }
/** * {@inheritDoc} */ @Override public SQLWarning getWarnings() throws SQLException { final RowSet rs = this.currentRowSet; SnappyExceptionData warning; if (rs != null) { warning = rs.getWarnings(); } else { warning = this.warnings; } if (warning != null) { return ThriftExceptionUtil.newSQLWarning(warning, null); } return null; }
/** * <code>setClientInfo</code> will throw a <code>SQLClientInfoException</code> * unless the <code>properties</code> paramenter is empty, since SnappyData does * not support any properties. */ @Override public void setClientInfo(Properties properties) throws SQLClientInfoException { if (properties != null && !properties.isEmpty()) { HashMap<String, ClientInfoStatus> failedProperties = new HashMap<>(properties.size()); String firstKey = null; for (String key : properties.stringPropertyNames()) { if (firstKey == null) { firstKey = key; } failedProperties.put(key, ClientInfoStatus.REASON_UNKNOWN_PROPERTY); } if (firstKey != null) { throw ThriftExceptionUtil.newSQLClientInfoException( SQLState.PROPERTY_UNSUPPORTED_CHANGE, failedProperties, null, firstKey, properties.getProperty(firstKey)); } } }
@Override public final ResultSet executeQuery(String sql) throws SQLException { throw ThriftExceptionUtil.newSQLException( SQLState.NOT_FOR_PREPARED_STATEMENT, null, "executeQuery(String)"); }
/** * {@inheritDoc} */ @Override public void setNCharacterStream(int parameterIndex, Reader value, long length) throws SQLException { throw ThriftExceptionUtil .notImplemented("PreparedStatement.setNCharacterStream"); }
throw ThriftExceptionUtil.newSnappyException( SQLState.LOCK_TIMEOUT, null, source.toString());
/** * {@inheritDoc} */ @Override public SQLWarning getWarnings() throws SQLException { checkClosed(); SnappyExceptionData warnings = this.rowSet.getWarnings(); if (warnings != null) { return ThriftExceptionUtil.newSQLWarning(warnings, null); } else { return null; } }
final SQLException nullRowException() { if (this.rowSet == null) { return ThriftExceptionUtil .newSQLException(SQLState.CLIENT_RESULT_SET_NOT_OPEN); } else { return ThriftExceptionUtil.newSQLException(SQLState.NO_CURRENT_ROW); } }
/** * {@inheritDoc} */ @Override public void updateRef(int columnIndex, Ref x) throws SQLException { throw ThriftExceptionUtil.notImplemented("ResultSet.updateRef"); }