亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产精品乱码久久久久久| 国产乱码精品一区二区三区忘忧草 | 激情五月婷婷综合| 成人av午夜影院| 日韩视频在线一区二区| 亚洲国产视频a| aaa亚洲精品| 亚洲美女在线一区| 91高清在线观看| 亚洲美女视频在线| 国产电影一区二区三区| 国产精品国产三级国产aⅴ中文| 国产在线播放一区三区四| 欧美mv日韩mv国产网站app| 日韩中文欧美在线| 精品久久一区二区| 国产成人免费在线观看不卡| 欧美极品aⅴ影院| 色欧美乱欧美15图片| 亚洲精品伦理在线| 欧美日韩视频在线第一区 | 美女性感视频久久| 高清不卡一区二区| 欧美日韩国产一级片| 亚洲成国产人片在线观看| 麻豆91小视频| 国产拍揄自揄精品视频麻豆| 国产不卡在线视频| 中文字幕一区二区三| 成人开心网精品视频| 亚洲美女屁股眼交3| 欧美日韩高清一区| 极品少妇xxxx精品少妇| 中文字幕一区二区三| 色8久久精品久久久久久蜜 | 99re成人在线| 亚洲成在线观看| 久久精品综合网| 91免费看片在线观看| 亚洲va天堂va国产va久| 欧美α欧美αv大片| 美国一区二区三区在线播放| 国产女人aaa级久久久级| 91在线观看污| 亚洲va韩国va欧美va| 国产日韩影视精品| 欧美日韩精品综合在线| 久久99久久久欧美国产| 中文字幕在线播放不卡一区| 日韩一区二区中文字幕| 成人精品亚洲人成在线| 亚洲一区电影777| 精品少妇一区二区三区在线播放| 91蜜桃婷婷狠狠久久综合9色| 日产国产高清一区二区三区| 国产女人水真多18毛片18精品视频 | 国产精品久久夜| 91精品福利视频| 亚洲精品一二三区| 26uuu国产一区二区三区| 色综合久久综合网欧美综合网| 久久精品一区八戒影视| 欧美大黄免费观看| 91久久人澡人人添人人爽欧美| 久久电影网站中文字幕| 成人免费在线视频| 亚洲国产经典视频| 欧美一区二区大片| 色婷婷久久久久swag精品| 久久国产视频网| 偷拍亚洲欧洲综合| 亚洲欧美日韩在线| 国产午夜精品理论片a级大结局 | 久久久久久久电影| 日韩精品一区二区三区在线播放| 波多野结衣在线aⅴ中文字幕不卡| 日韩黄色片在线观看| 成人欧美一区二区三区视频网页| 91麻豆精品国产91久久久久| 欧美久久久一区| 92国产精品观看| 成人av电影在线| 日本美女一区二区三区| 日韩黄色一级片| 午夜视频在线观看一区| 亚洲免费在线观看| 亚洲免费av在线| 亚洲综合激情另类小说区| 亚洲欧美二区三区| 国产精品乱码一区二三区小蝌蚪| 久久综合狠狠综合久久激情| 波多野结衣视频一区| 91丨porny丨国产入口| 国产乱子伦视频一区二区三区| 美女爽到高潮91| 久久精品国产99国产精品| 樱桃国产成人精品视频| 一区二区三区国产| 亚洲一区在线观看视频| 亚洲美女在线国产| 亚洲第四色夜色| 国产亚洲精品7777| 国产人成一区二区三区影院| 国产亚洲一区二区三区四区| 91精品国产一区二区三区蜜臀| 欧美日韩国产精选| 91麻豆精品国产综合久久久久久| 9191成人精品久久| 欧美色大人视频| 日韩精品一区二区三区四区| 欧美大片在线观看一区| 久久久久亚洲蜜桃| 国产精品欧美久久久久无广告 | 老色鬼精品视频在线观看播放| 国产一二精品视频| 成熟亚洲日本毛茸茸凸凹| 99在线视频精品| 欧美又粗又大又爽| 欧美日韩国产a| 精品久久久久久久久久久久包黑料 | 久久伊99综合婷婷久久伊| 国产精品免费久久久久| 亚洲国产精品一区二区久久恐怖片| 日韩精品亚洲一区二区三区免费| 亚洲一二三四在线观看| 日本不卡一二三| 国产精品一区二区三区99| 不卡的电影网站| 在线电影欧美成精品| 26uuuu精品一区二区| 国产精品国产三级国产普通话99| 一区二区激情视频| 中文字幕成人av| 亚洲国产精品天堂| 国产中文字幕一区| 成人h动漫精品| 欧美电影在线免费观看| 欧美成人a在线| 亚洲综合一区在线| 黄一区二区三区| 成人国产精品免费| 欧美日韩一区小说| 欧美一区二区三区视频在线观看| 久久综合色8888| 日韩影视精彩在线| 91蜜桃婷婷狠狠久久综合9色| 久久久久国产精品麻豆| 日韩不卡在线观看日韩不卡视频| 99国产精品久久久| 久久精品人人做人人爽人人| 奇米777欧美一区二区| 91浏览器在线视频| 欧美国产97人人爽人人喊| 麻豆成人久久精品二区三区红 | 欧美亚洲一区二区在线| 国产精品福利一区二区三区| 国产在线视频精品一区| 日韩欧美www| 免费观看成人av| 欧美一三区三区四区免费在线看| 亚洲伊人色欲综合网| 成人激情校园春色| 久久久久国产精品人| 国产精品主播直播| 久久一二三国产| 国产精品资源在线| 国产亚洲欧美激情| 夫妻av一区二区| 久久综合九色综合久久久精品综合| 日本午夜一区二区| 欧美一区二区久久| 美女脱光内衣内裤视频久久网站 | 亚洲图片你懂的| 不卡av免费在线观看| 亚洲欧洲性图库| 91在线视频18| 一区二区欧美在线观看| 欧美日韩久久一区| 免费观看在线综合| wwww国产精品欧美| 国产福利精品导航| 国产精品久久久久久亚洲毛片 | 亚洲一区在线视频观看| 欧美亚洲一区二区在线观看| 日韩国产在线一| 欧美视频精品在线观看| 日本视频一区二区三区| 欧美一区二区性放荡片| 免费成人av在线| 久久久久久久网| 成人免费视频caoporn| 欧美激情一区在线观看| 99国产精品久久| 视频一区欧美日韩| 在线成人午夜影院| 狠狠色综合色综合网络| 国产欧美一区二区三区网站| 91久久精品一区二区三区| 日本不卡的三区四区五区| 久久久国产精品不卡|