亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sqlexecutor.java

?? 本套系統采用了業界當前最為流行的beanAction組件
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 *  Copyright 2004 Clinton Begin
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.ibatis.sqlmap.engine.execution;

import com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping;
import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMap;
import com.ibatis.sqlmap.engine.mapping.parameter.ParameterMapping;
import com.ibatis.sqlmap.engine.mapping.result.ResultMap;
import com.ibatis.sqlmap.engine.mapping.result.ResultObjectFactoryUtil;
import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement;
import com.ibatis.sqlmap.engine.mapping.statement.RowHandlerCallback;
import com.ibatis.sqlmap.engine.scope.ErrorContext;
import com.ibatis.sqlmap.engine.scope.RequestScope;
import com.ibatis.sqlmap.engine.scope.SessionScope;
import com.ibatis.sqlmap.engine.impl.ExtendedSqlMapClient;
import com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate;
import com.ibatis.sqlmap.engine.mapping.statement.DefaultRowHandler;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Class responsible for executing the SQL
 */
public class SqlExecutor {

  //
  // Constants
  //
  /**
   * Constant to let us know not to skip anything
   */
  public static final int NO_SKIPPED_RESULTS = 0;
  /**
   * Constant to let us know to include all records
   */
  public static final int NO_MAXIMUM_RESULTS = -999999;

  //
  // Public Methods
  //

  /**
   * Execute an update
   *
   * @param request    - the request scope
   * @param conn       - the database connection
   * @param sql        - the sql statement to execute
   * @param parameters - the parameters for the sql statement
   * @return - the number of records changed
   * @throws SQLException - if the update fails
   */
  public int executeUpdate(RequestScope request, Connection conn, String sql, Object[] parameters) throws SQLException {
    ErrorContext errorContext = request.getErrorContext();
    errorContext.setActivity("executing update");
    errorContext.setObjectId(sql);
    PreparedStatement ps = null;
    setupResultObjectFactory(request);
    int rows = 0;
    try {
      errorContext.setMoreInfo("Check the SQL Statement (preparation failed).");
      ps = prepareStatement(request.getSession(), conn, sql);
      setStatementTimeout(request.getStatement(), ps);
      errorContext.setMoreInfo("Check the parameters (set parameters failed).");
      request.getParameterMap().setParameters(request, ps, parameters);
      errorContext.setMoreInfo("Check the statement (update failed).");
      ps.execute();
      rows = ps.getUpdateCount();
    } finally {
      closeStatement(request.getSession(), ps);
    }
    return rows;
  }

  /**
   * Adds a statement to a batch
   *
   * @param request    - the request scope
   * @param conn       - the database connection
   * @param sql        - the sql statement
   * @param parameters - the parameters for the statement
   * @throws SQLException - if the statement fails
   */
  public void addBatch(RequestScope request, Connection conn, String sql, Object[] parameters) throws SQLException {
    Batch batch = (Batch) request.getSession().getBatch();
    if (batch == null) {
      batch = new Batch();
      request.getSession().setBatch(batch);
    }
    batch.addBatch(request, conn, sql, parameters);
  }

  /**
   * Execute a batch of statements
   *
   * @param session - the session scope
   * @return - the number of rows impacted by the batch
   * @throws SQLException - if a statement fails
   */
  public int executeBatch(SessionScope session) throws SQLException {
    int rows = 0;
    Batch batch = (Batch) session.getBatch();
    if (batch != null) {
      try {
        rows = batch.executeBatch();
      } finally {
        batch.cleanupBatch(session);
      }
    }
    return rows;
  }

  /**
   * Execute a batch of statements
   *
   * @param session - the session scope
   * @return - a List of BatchResult objects (may be null if no batch
   *         has been initiated).  There will be one BatchResult object in the
   *         list for each sub-batch executed
   * @throws SQLException   if a database access error occurs, or the drive
   *                        does not support batch statements
   * @throws BatchException if the driver throws BatchUpdateException
   */
  public List executeBatchDetailed(SessionScope session) throws SQLException, BatchException {
    List answer = null;
    Batch batch = (Batch) session.getBatch();
    if (batch != null) {
      try {
        answer = batch.executeBatchDetailed();
      } finally {
        batch.cleanupBatch(session);
      }
    }
    return answer;
  }

  /**
   * Long form of the method to execute a query
   *
   * @param request     - the request scope
   * @param conn        - the database connection
   * @param sql         - the SQL statement to execute
   * @param parameters  - the parameters for the statement
   * @param skipResults - the number of results to skip
   * @param maxResults  - the maximum number of results to return
   * @param callback    - the row handler for the query
   * @throws SQLException - if the query fails
   */
  public void executeQuery(RequestScope request, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException {
    ErrorContext errorContext = request.getErrorContext();
    errorContext.setActivity("executing query");
    errorContext.setObjectId(sql);
    PreparedStatement ps = null;
    ResultSet rs = null;
    setupResultObjectFactory(request);
    try {
      errorContext.setMoreInfo("Check the SQL Statement (preparation failed).");
      Integer rsType = request.getStatement().getResultSetType();
      if (rsType != null) {
        ps = prepareStatement(request.getSession(), conn, sql, rsType);
      } else {
        ps = prepareStatement(request.getSession(), conn, sql);
      }
      setStatementTimeout(request.getStatement(), ps);
      Integer fetchSize = request.getStatement().getFetchSize();
      if (fetchSize != null) {
        ps.setFetchSize(fetchSize.intValue());
      }
      errorContext.setMoreInfo("Check the parameters (set parameters failed).");
      request.getParameterMap().setParameters(request, ps, parameters);
      errorContext.setMoreInfo("Check the statement (query failed).");
      ps.execute();
      errorContext.setMoreInfo("Check the results (failed to retrieve results).");

      // Begin ResultSet Handling
      rs = handleMultipleResults(ps, request, skipResults, maxResults, callback);
      // End ResultSet Handling
    } finally {
      try {
        closeResultSet(rs);
      } finally {
        closeStatement(request.getSession(), ps);
      }
    }

  }

  /**
   * Execute a stored procedure that updates data
   *
   * @param request    - the request scope
   * @param conn       - the database connection
   * @param sql        - the SQL to call the procedure
   * @param parameters - the parameters for the procedure
   * @return - the rows impacted by the procedure
   * @throws SQLException - if the procedure fails
   */
  public int executeUpdateProcedure(RequestScope request, Connection conn, String sql, Object[] parameters) throws SQLException {
    ErrorContext errorContext = request.getErrorContext();
    errorContext.setActivity("executing update procedure");
    errorContext.setObjectId(sql);
    CallableStatement cs = null;
    setupResultObjectFactory(request);
    int rows = 0;
    try {
      errorContext.setMoreInfo("Check the SQL Statement (preparation failed).");
      cs = prepareCall(request.getSession(), conn, sql);
      setStatementTimeout(request.getStatement(), cs);
      ParameterMap parameterMap = request.getParameterMap();
      ParameterMapping[] mappings = parameterMap.getParameterMappings();
      errorContext.setMoreInfo("Check the output parameters (register output parameters failed).");
      registerOutputParameters(cs, mappings);
      errorContext.setMoreInfo("Check the parameters (set parameters failed).");
      parameterMap.setParameters(request, cs, parameters);
      errorContext.setMoreInfo("Check the statement (update procedure failed).");
      cs.execute();
      rows = cs.getUpdateCount();
      errorContext.setMoreInfo("Check the output parameters (retrieval of output parameters failed).");
      retrieveOutputParameters(request, cs, mappings, parameters, null);
    } finally {
      closeStatement(request.getSession(), cs);
    }
    return rows;
  }

  /**
   * Execute a stored procedure
   *
   * @param request     - the request scope
   * @param conn        - the database connection
   * @param sql         - the sql to call the procedure
   * @param parameters  - the parameters for the procedure
   * @param skipResults - the number of results to skip
   * @param maxResults  - the maximum number of results to return
   * @param callback    - a row handler for processing the results
   * @throws SQLException - if the procedure fails
   */
  public void executeQueryProcedure(RequestScope request, Connection conn, String sql, Object[] parameters, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException {
    ErrorContext errorContext = request.getErrorContext();
    errorContext.setActivity("executing query procedure");
    errorContext.setObjectId(sql);
    CallableStatement cs = null;
    ResultSet rs = null;
    setupResultObjectFactory(request);
    try {
      errorContext.setMoreInfo("Check the SQL Statement (preparation failed).");
      Integer rsType = request.getStatement().getResultSetType();
      if (rsType != null) {
        cs = prepareCall(request.getSession(), conn, sql, rsType);
      } else {
        cs = prepareCall(request.getSession(), conn, sql);
      }
      setStatementTimeout(request.getStatement(), cs);
      Integer fetchSize = request.getStatement().getFetchSize();
      if (fetchSize != null) {
        cs.setFetchSize(fetchSize.intValue());
      }
      ParameterMap parameterMap = request.getParameterMap();
      ParameterMapping[] mappings = parameterMap.getParameterMappings();
      errorContext.setMoreInfo("Check the output parameters (register output parameters failed).");
      registerOutputParameters(cs, mappings);
      errorContext.setMoreInfo("Check the parameters (set parameters failed).");
      parameterMap.setParameters(request, cs, parameters);
      errorContext.setMoreInfo("Check the statement (update procedure failed).");
      cs.execute();
      errorContext.setMoreInfo("Check the results (failed to retrieve results).");

      // Begin ResultSet Handling
      rs = handleMultipleResults(cs, request, skipResults, maxResults, callback);
      // End ResultSet Handling
      errorContext.setMoreInfo("Check the output parameters (retrieval of output parameters failed).");
      retrieveOutputParameters(request, cs, mappings, parameters, callback);

    } finally {
      try {
        closeResultSet(rs);
      } finally {
        closeStatement(request.getSession(), cs);
      }
    }
  }

  private ResultSet handleMultipleResults(PreparedStatement ps, RequestScope request, int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException {
    ResultSet rs;
    rs = getFirstResultSet(ps);
    if (rs != null) {
      handleResults(request, rs, skipResults, maxResults, callback);
    }

    // Multiple ResultSet handling
    if (callback.getRowHandler() instanceof DefaultRowHandler) {
      MappedStatement statement = request.getStatement();
      DefaultRowHandler defaultRowHandler = ((DefaultRowHandler) callback.getRowHandler());
      if (statement.hasMultipleResultMaps()) {
        List multipleResults = new ArrayList();
        multipleResults.add(defaultRowHandler.getList());
        ResultMap[] resultMaps = statement.getAdditionalResultMaps();
        int i = 0;
        while (moveToNextResultsSafely(ps)) {
          if (i >= resultMaps.length) break;
          ResultMap rm = resultMaps[i];
          request.setResultMap(rm);
          rs = ps.getResultSet();
          DefaultRowHandler rh = new DefaultRowHandler();
          handleResults(request, rs, skipResults, maxResults, new RowHandlerCallback(rm, null, rh));
          multipleResults.add(rh.getList());
          i++;
        }
        defaultRowHandler.setList(multipleResults);
        request.setResultMap(statement.getResultMap());
      } else {
        while (moveToNextResultsSafely(ps)) ;
      }
    }
    // End additional ResultSet handling
    return rs;
  }

  private ResultSet getFirstResultSet(Statement stmt) throws SQLException {
    ResultSet rs = null;
    boolean hasMoreResults = true;
    while (hasMoreResults) {
      rs = stmt.getResultSet();
      if (rs != null) {
        break;
      }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美v国产在线一区二区三区| 国产福利不卡视频| 欧美男生操女生| 亚洲一区二区三区四区在线| 欧美亚男人的天堂| 亚洲成a人v欧美综合天堂| 欧美一区二区三区免费视频 | 91精品福利在线一区二区三区| 午夜影院在线观看欧美| 日韩欧美自拍偷拍| 国产盗摄一区二区| 一区二区三区成人在线视频| 制服丝袜日韩国产| 国产高清精品网站| 一级精品视频在线观看宜春院| 欧美日韩高清一区二区三区| 激情欧美一区二区| 亚洲视频一区二区在线| 欧美精品乱人伦久久久久久| 激情av综合网| 亚洲黄色尤物视频| 欧美xxxx老人做受| 一本色道久久综合亚洲91| 日本成人中文字幕| 国产精品久久99| 欧美一区二区在线免费观看| 国产成人一区在线| 亚洲777理论| 国产精品欧美综合在线| 在线播放/欧美激情| 大陆成人av片| 美女一区二区久久| 亚洲乱码国产乱码精品精小说 | 久久综合网色—综合色88| 不卡一区二区中文字幕| 视频一区中文字幕国产| 欧美国产视频在线| 91精品国产欧美一区二区| 成人av中文字幕| 乱一区二区av| 亚洲成人自拍网| 国产精品久久久久永久免费观看| 91精品国产综合久久久蜜臀图片| www.亚洲在线| 国产麻豆视频精品| 天堂一区二区在线免费观看| 国产精品久久久久久久第一福利| 欧美一区二区免费视频| 色综合天天天天做夜夜夜夜做| 捆绑紧缚一区二区三区视频| 亚洲一区二区三区四区中文字幕| 亚洲国产精品ⅴa在线观看| 日韩一区二区三区免费观看| 色伊人久久综合中文字幕| 国产精品99久久久久久久vr| 美女视频一区二区三区| 亚洲高清免费在线| 亚洲综合色婷婷| 亚洲欧洲日本在线| 国产日韩欧美高清在线| 日韩精品影音先锋| 欧美日韩精品免费观看视频| 一本色道久久综合精品竹菊| 成人激情免费视频| 国产成人av资源| 国产麻豆精品视频| 久久精品99久久久| 免费看日韩a级影片| 午夜伊人狠狠久久| 亚洲成av人片一区二区| 亚洲第一激情av| 亚洲一区二区欧美激情| 亚洲伦理在线精品| 亚洲一区二区中文在线| 一区av在线播放| 亚洲一区二区成人在线观看| 亚洲精品乱码久久久久久久久| 国产精品―色哟哟| 中文字幕亚洲成人| 亚洲精品视频观看| 亚洲一区二区三区三| 亚洲一区二区中文在线| 午夜成人免费视频| 毛片一区二区三区| 国产在线精品免费av| 国产精品一区二区三区乱码| 国产91精品在线观看| 成人一区二区三区视频在线观看| 成人免费高清视频| 91国产成人在线| 欧美高清你懂得| 日韩精品一区二区三区老鸭窝| 26uuu欧美日本| 国产精品欧美经典| 亚洲午夜在线视频| 麻豆精品视频在线观看视频| 韩国成人在线视频| 成人国产在线观看| 欧美午夜精品理论片a级按摩| 欧美肥胖老妇做爰| 久久综合久久综合亚洲| 国产精品情趣视频| 午夜精品久久久久久久蜜桃app| 全国精品久久少妇| 成人国产亚洲欧美成人综合网| 在线观看欧美日本| 日韩欧美国产综合| 国产精品国产三级国产普通话99 | 极品少妇xxxx精品少妇| 国产成人在线免费观看| 99精品1区2区| 日韩一级二级三级| 国产精品久久福利| 秋霞午夜鲁丝一区二区老狼| 国产成人亚洲综合a∨婷婷图片| 色悠悠亚洲一区二区| 精品日韩欧美在线| 一区二区久久久久久| 激情国产一区二区| 91成人在线观看喷潮| 欧美精品一区二区三区一线天视频| 自拍偷在线精品自拍偷无码专区| 视频一区二区不卡| 成人黄动漫网站免费app| 日韩一区二区三区视频| 亚洲精品菠萝久久久久久久| 日本视频在线一区| 一本久久a久久精品亚洲| 日韩精品一区二区三区视频播放 | 国产精品欧美一区喷水| 日韩高清一级片| 91一区在线观看| 精品成人一区二区| 午夜欧美在线一二页| 成人黄色小视频在线观看| 日韩欧美国产成人一区二区| 悠悠色在线精品| 成人国产在线观看| 2023国产精品| 奇米色777欧美一区二区| 99精品视频在线免费观看| 精品国产露脸精彩对白| 婷婷综合另类小说色区| 色偷偷久久一区二区三区| 中文一区在线播放| 国产东北露脸精品视频| 欧美二区在线观看| 亚洲午夜激情网站| 91麻豆精品一区二区三区| 日本一区二区三级电影在线观看 | 懂色av中文一区二区三区| 91精品综合久久久久久| 亚洲综合久久久久| 91免费看`日韩一区二区| 国产午夜精品久久久久久免费视| 久久狠狠亚洲综合| 精品久久久久久亚洲综合网| 日本成人在线视频网站| 91精品国产91久久久久久最新毛片 | 成人不卡免费av| 久久精子c满五个校花| 国产一区啦啦啦在线观看| 欧美成人a在线| 精品一二三四在线| 久久丝袜美腿综合| 国产91在线看| 国产精品网站一区| 91麻豆国产在线观看| 一区二区在线观看av| 91国在线观看| 亚洲123区在线观看| 欧美日本国产视频| 麻豆精品视频在线观看| 精品卡一卡二卡三卡四在线| 精品写真视频在线观看| 久久蜜臀精品av| 波多野结衣亚洲| 一级特黄大欧美久久久| 欧美精品乱码久久久久久| 日本不卡在线视频| 久久蜜桃av一区精品变态类天堂 | 日本不卡一区二区三区| 日韩限制级电影在线观看| 精品一区二区三区av| 久久久99精品久久| 91亚洲大成网污www| 亚洲午夜精品久久久久久久久| 91精品午夜视频| 国产一区在线不卡| 亚洲免费观看高清完整版在线观看熊 | 欧美亚洲国产一卡| 美女视频一区在线观看| 久久久久一区二区三区四区| 国产成人免费视频精品含羞草妖精| 亚洲欧洲精品一区二区三区不卡 | 91精品国产美女浴室洗澡无遮挡| 久久99国产精品免费| 国产精品久久久久影视| 欧美日韩精品专区| 国产高清不卡一区二区|