Codota Logo
ExecutorExceptionHandler
Code IndexAdd Codota to your IDE (free)

How to use
ExecutorExceptionHandler
in
org.apache.shardingsphere.core.executor.sql.execute.threadlocal

Best Java code snippets using org.apache.shardingsphere.core.executor.sql.execute.threadlocal.ExecutorExceptionHandler (Showing top 12 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: apache/incubator-shardingsphere

  /**
   * Handle exception. 
   * 
   * @param exception to be handled exception
   * @throws SQLException SQL exception
   */
  public static void handleException(final Exception exception) throws SQLException {
    if (isExceptionThrown()) {
      if (exception instanceof SQLException) {
        throw (SQLException) exception;
      }
      throw new ShardingException(exception);
    }
    log.error("exception occur: ", exception);
  }
}
origin: apache/incubator-shardingsphere

  /**
   * Execute group.
   *
   * @param sqlExecuteGroups SQL execute groups
   * @param firstCallback first SQL execute callback
   * @param callback SQL execute callback
   * @param <T> class type of return value
   * @return execute result
   * @throws SQLException SQL exception
   */
  @SuppressWarnings("unchecked")
  public <T> List<T> executeGroup(final Collection<ShardingExecuteGroup<? extends StatementExecuteUnit>> sqlExecuteGroups,
                  final SQLExecuteCallback<T> firstCallback, final SQLExecuteCallback<T> callback) throws SQLException {
    try {
      return executeEngine.groupExecute((Collection) sqlExecuteGroups, firstCallback, callback, serial);
    } catch (final SQLException ex) {
      ExecutorExceptionHandler.handleException(ex);
      return Collections.emptyList();
    }
  }
}
origin: apache/incubator-shardingsphere

private T execute0(final StatementExecuteUnit statementExecuteUnit, final boolean isTrunkThread, final Map<String, Object> shardingExecuteDataMap) throws SQLException {
  ExecutorExceptionHandler.setExceptionThrown(isExceptionThrown);
  DataSourceMetaData dataSourceMetaData = DataSourceMetaDataFactory.newInstance(databaseType, statementExecuteUnit.getDatabaseMetaData().getURL());
  SQLExecutionHook sqlExecutionHook = new SPISQLExecutionHook();
  try {
    sqlExecutionHook.start(statementExecuteUnit.getRouteUnit(), dataSourceMetaData, isTrunkThread, shardingExecuteDataMap);
    T result = executeSQL(statementExecuteUnit);
    sqlExecutionHook.finishSuccess();
    return result;
  } catch (final SQLException ex) {
    sqlExecutionHook.finishFailure(ex);
    ExecutorExceptionHandler.handleException(ex);
    return null;
  }
}

origin: apache/incubator-shardingsphere

private boolean execute(final Executor executor) throws SQLException {
  final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  SQLExecuteCallback<Boolean> executeCallback = new SQLExecuteCallback<Boolean>(getDatabaseType(), isExceptionThrown) {
    
    @Override
    protected Boolean executeSQL(final StatementExecuteUnit statementExecuteUnit) throws SQLException {
      return executor.execute(statementExecuteUnit.getStatement(), statementExecuteUnit.getRouteUnit().getSqlUnit().getSql());
    }
  };
  List<Boolean> result = executeCallback(executeCallback);
  if (null == result || result.isEmpty() || null == result.get(0)) {
    return false;
  }
  return result.get(0);
}

origin: apache/incubator-shardingsphere

  /**
   * Execute SQL.
   *
   * @return return true if is DQL, false if is DML
   * @throws SQLException SQL exception
   */
  public boolean execute() throws SQLException {
    boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
    SQLExecuteCallback<Boolean> executeCallback = SQLExecuteCallbackFactory.getPreparedSQLExecuteCallback(getDatabaseType(), isExceptionThrown);
    List<Boolean> result = executeCallback(executeCallback);
    if (null == result || result.isEmpty() || null == result.get(0)) {
      return false;
    }
    return result.get(0);
  }
}
origin: apache/incubator-shardingsphere

/**
 * Execute query.
 *
 * @return result set list
 * @throws SQLException SQL exception
 */
public List<QueryResult> executeQuery() throws SQLException {
  final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  SQLExecuteCallback<QueryResult> executeCallback = new SQLExecuteCallback<QueryResult>(getDatabaseType(), isExceptionThrown) {
    
    @Override
    protected QueryResult executeSQL(final StatementExecuteUnit statementExecuteUnit) throws SQLException {
      return getQueryResult(statementExecuteUnit);
    }
  };
  return executeCallback(executeCallback);
}

origin: apache/incubator-shardingsphere

/**
 * Execute query.
 * 
 * @return result set list
 * @throws SQLException SQL exception
 */
public List<QueryResult> executeQuery() throws SQLException {
  final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  SQLExecuteCallback<QueryResult> executeCallback = new SQLExecuteCallback<QueryResult>(getDatabaseType(), isExceptionThrown) {
    
    @Override
    protected QueryResult executeSQL(final StatementExecuteUnit statementExecuteUnit) throws SQLException {
      return getQueryResult(statementExecuteUnit);
    }
  };
  return executeCallback(executeCallback);
}

origin: apache/incubator-shardingsphere

private int executeUpdate(final Updater updater) throws SQLException {
  final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  SQLExecuteCallback<Integer> executeCallback = new SQLExecuteCallback<Integer>(getDatabaseType(), isExceptionThrown) {
    
    @Override
    protected Integer executeSQL(final StatementExecuteUnit statementExecuteUnit) throws SQLException {
      return updater.executeUpdate(statementExecuteUnit.getStatement(), statementExecuteUnit.getRouteUnit().getSqlUnit().getSql());
    }
  };
  List<Integer> results = executeCallback(executeCallback);
  if (isAccumulate()) {
    return accumulate(results);
  } else {
    return null == results.get(0) ? 0 : results.get(0);
  }
}

origin: apache/incubator-shardingsphere

/**
 * Execute batch.
 * 
 * @return execute results
 * @throws SQLException SQL exception
 */
public int[] executeBatch() throws SQLException {
  final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  SQLExecuteCallback<int[]> callback = new SQLExecuteCallback<int[]>(getDatabaseType(), isExceptionThrown) {
    
    @Override
    protected int[] executeSQL(final StatementExecuteUnit statementExecuteUnit) throws SQLException {
      return statementExecuteUnit.getStatement().executeBatch();
    }
  };
  List<int[]> results = executeCallback(callback);
  if (isAccumulate()) {
    return accumulate(results);
  } else {
    return results.get(0);
  }
}

origin: apache/incubator-shardingsphere

/**
 * Execute update.
 * 
 * @return effected records count
 * @throws SQLException SQL exception
 */
public int executeUpdate() throws SQLException {
  final boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  SQLExecuteCallback<Integer> executeCallback = SQLExecuteCallbackFactory.getPreparedUpdateSQLExecuteCallback(getDatabaseType(), isExceptionThrown);
  List<Integer> results = executeCallback(executeCallback);
  if (isAccumulate()) {
    return accumulate(results);
  } else {
    return results.get(0);
  }
}

origin: apache/incubator-shardingsphere

@SuppressWarnings("unchecked")
@Override
public ExecuteResponse execute(final SQLRouteResult routeResult) throws SQLException {
  boolean isReturnGeneratedKeys = routeResult.getSqlStatement() instanceof InsertStatement;
  boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  Collection<ShardingExecuteGroup<StatementExecuteUnit>> sqlExecuteGroups =
      sqlExecutePrepareTemplate.getExecuteUnitGroups(routeResult.getRouteUnits(), new ProxyJDBCExecutePrepareCallback(isReturnGeneratedKeys));
  SQLExecuteCallback<ExecuteResponseUnit> firstProxySQLExecuteCallback = new FirstProxyJDBCExecuteCallback(isExceptionThrown, isReturnGeneratedKeys);
  SQLExecuteCallback<ExecuteResponseUnit> proxySQLExecuteCallback = new ProxyJDBCExecuteCallback(isExceptionThrown, isReturnGeneratedKeys);
  Collection<ExecuteResponseUnit> executeResponseUnits = sqlExecuteTemplate.executeGroup((Collection) sqlExecuteGroups,
      firstProxySQLExecuteCallback, proxySQLExecuteCallback);
  ExecuteResponseUnit firstExecuteResponseUnit = executeResponseUnits.iterator().next();
  return firstExecuteResponseUnit instanceof ExecuteQueryResponseUnit
      ? getExecuteQueryResponse(((ExecuteQueryResponseUnit) firstExecuteResponseUnit).getQueryResponsePackets(), executeResponseUnits) : new ExecuteUpdateResponse(executeResponseUnits);
}

origin: apache/incubator-shardingsphere

@SuppressWarnings("unchecked")
@Override
public ExecuteResponse execute(final SQLRouteResult routeResult) throws SQLException {
  boolean isReturnGeneratedKeys = routeResult.getSqlStatement() instanceof InsertStatement;
  boolean isExceptionThrown = ExecutorExceptionHandler.isExceptionThrown();
  Collection<ShardingExecuteGroup<StatementExecuteUnit>> sqlExecuteGroups =
    sqlExecutePrepareTemplate.getExecuteUnitGroups(routeResult.getRouteUnits(), new ProxyJDBCExecutePrepareCallback(isReturnGeneratedKeys));
  SQLExecuteCallback<ExecuteResponseUnit> firstProxySQLExecuteCallback = new FirstProxyJDBCExecuteCallback(isExceptionThrown, isReturnGeneratedKeys);
  SQLExecuteCallback<ExecuteResponseUnit> proxySQLExecuteCallback = new ProxyJDBCExecuteCallback(isExceptionThrown, isReturnGeneratedKeys);
  Collection<ExecuteResponseUnit> executeResponseUnits = sqlExecuteTemplate.executeGroup((Collection) sqlExecuteGroups,
    firstProxySQLExecuteCallback, proxySQLExecuteCallback);
  ExecuteResponseUnit firstExecuteResponseUnit = executeResponseUnits.iterator().next();
  return firstExecuteResponseUnit instanceof ExecuteQueryResponseUnit
    ? getExecuteQueryResponse(((ExecuteQueryResponseUnit) firstExecuteResponseUnit).getPostgreSQLQueryResponsePackets(), executeResponseUnits)
    : new ExecuteUpdateResponse(executeResponseUnits);
}

org.apache.shardingsphere.core.executor.sql.execute.threadlocalExecutorExceptionHandler

Javadoc

Executor runtime exception handler.

Most used methods

  • isExceptionThrown
    Get throw exception if error occur or not.
  • handleException
    Handle exception.
  • setExceptionThrown
    Set throw exception if error occur or not.

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • getSharedPreferences (Context)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • JPanel (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now