shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/communication/DatabaseCommunicationEngine.java
/**
     * Execute to database.
     *
     * @return backend response
     * @throws SQLException SQL exception
     */
Execute to database.
@return backend response
@throws SQLException SQL exception
Execute to database . @return backend response @throws SQLException SQL exception
public ResponseHeader execute() throws SQLException {
        ExecutionContext executionContext = kernelProcessor.generateExecutionContext(logicSQL, metaData, ProxyContext.getInstance().getContextManager().getMetaDataContexts().getProps());
        if (executionContext.getExecutionUnits().isEmpty()) {
            return new UpdateResponseHeader(executionContext.getSqlStatementContext().getSqlStatement());
        }
        proxySQLExecutor.checkExecutePrerequisites(executionContext);
        Collection<ExecuteResult> executeResults = proxyLockEngine.execute(executionContext);
        ExecuteResult executeResultSample = executeResults.iterator().next();
        return executeResultSample instanceof QueryResult
                ? processExecuteQuery(executionContext, executeResults.stream().map(each -> (QueryResult) each).collect(Collectors.toList()), (QueryResult) executeResultSample)
                : processExecuteUpdate(executionContext, executeResults.stream().map(each -> (UpdateResult) each).collect(Collectors.toList()));
    }
public ResponseHeader execute ( ) throws SQLException { ExecutionContext executionContext = kernelProcessor . generateExecutionContext ( logicSQL , metaData , ProxyContext . getInstance ( ) . getContextManager ( ) . getMetaDataContexts ( ) . getProps ( ) ) ; if ( executionContext . getExecutionUnits ( ) . isEmpty ( ) ) { return new UpdateResponseHeader ( executionContext . getSqlStatementContext ( ) . getSqlStatement ( ) ) ; } proxySQLExecutor . checkExecutePrerequisites ( executionContext ) ; Collection < ExecuteResult > executeResults = proxyLockEngine . execute ( executionContext ) ; ExecuteResult executeResultSample = executeResults . iterator ( ) . next ( ) ; return executeResultSample instanceof QueryResult ? processExecuteQuery ( executionContext , executeResults . stream ( ) . map ( each -> ( QueryResult ) each ) . collect ( Collectors . toList ( ) ) , ( QueryResult ) executeResultSample ) : processExecuteUpdate ( executionContext , executeResults . stream ( ) . map ( each -> ( UpdateResult ) each ) . collect ( Collectors . toList ( ) ) ) ; }
Execute to database.
Execute to database .