执行调用存储过程<br>
此方法不会关闭Connection

@param conn 数据库连接对象
@param sql SQL
@param params 参数
@return 如果执行后第一个结果是ResultSet，则返回true，否则返回false。
@throws SQLException SQL执行异常
344123
public static boolean call(Connection conn, String sql, Object... params) throws SQLException {
		CallableStatement call = null;
		try {
			call = StatementUtil.prepareCall(conn, sql, params);
			return call.execute();
		} finally {
			DbUtil.close(call);
		}
	}
217497
public function sqlExecute(string $sql, array $params = []): int
    {
        return $this->connection()->sqlExecute($sql, $params);
    }
886180
@Override
    public ResultSet executeQuery() throws SQLException
    {
        checkClosed();
        if (!this.Query.isOfType(VoltSQL.TYPE_EXEC,VoltSQL.TYPE_SELECT)) {
            throw SQLError.get(SQLError.ILLEGAL_STATEMENT, this.Query.toSqlString());
        }
        ResultSet result = this.executeQuery(this.Query.getExecutableQuery(this.parameters));
        this.parameters = this.Query.getParameterArray();
        return result;
    }
1043739
public <S> S queryOne(Class<S> type, String sql, Object[] params) {
        Connection conn = getConn();
        try {
            Query query = conn.createQuery(sql)
                    .withParams(params)
                    .setAutoDeriveColumnNames(true)
                    .throwOnMappingFailure(false);

            return ifReturn(AnimaUtils.isBasicType(type),
                    () -> query.executeScalar(type),
                    () -> query.executeAndFetchFirst(type));
        } finally {
            this.closeConn(conn);
            this.clean(null);
        }
    }
221094
public static void returnConnection(Connection conn) throws SQLException {
        if (conn == null) {
            return;
        }
        String dsName = openConnDsName.get().get(conn);
        OpenConnStats connStats = dsName != null ? openConnStats.get().get(dsName) : null;
        if (connStats == null) {
            conn.close();
        } else {
            long value = connStats.counter.decrementAndGet();
            if (value <= 0) {
                try {
                    try {
                        if (connStats.inTransaction) {
                            conn.commit();
                        }
                    } catch (Exception e) {
                        conn.rollback();
                    } finally {
                        try {
                            conn.setAutoCommit(true);
                        } finally {
                            connStats.inTransaction = false;
                            conn.close();
                        }
                    }
                } finally {
                    openConnStats.get().remove(dsName);
                    openConnDsName.get().remove(conn);
                }
            }
        }
    }
961280
public <T> T query(String sql, RsHandler<T> rsh, Object... params) throws SQLException {
		Connection conn = null;
		try {
			conn = this.getConnection();
			return SqlExecutor.query(conn, sql, rsh, params);
		} catch (SQLException e) {
			throw e;
		} finally {
			this.closeConnection(conn);
		}
	}
311198
public SQLException exceptionWithQuery(ParameterHolder[] parameters, SQLException sqlEx,
      PrepareResult serverPrepareResult) {
    if (sqlEx.getCause() instanceof SocketTimeoutException) {
      return new SQLException("Connection timed out", CONNECTION_EXCEPTION.getSqlState(), sqlEx);
    }
    if (options.dumpQueriesOnException) {
      return new SQLException(exWithQuery(sqlEx.getMessage(), serverPrepareResult, parameters),
          sqlEx.getSQLState(),
          sqlEx.getErrorCode(), sqlEx.getCause());
    }
    return sqlEx;
  }
570331
public static int[] executeBatch(Connection conn, String sql, Iterable<Object[]> paramsBatch) throws SQLException {
		PreparedStatement ps = null;
		try {
			ps = StatementUtil.prepareStatementForBatch(conn, sql, paramsBatch);
			return ps.executeBatch();
		} finally {
			DbUtil.close(ps);
		}
	}
124749
boolean executeInternal(String sql,
                          Map<String, ParameterBindingDTO> parameterBindings)
  throws SQLException
  {
    raiseSQLExceptionIfStatementIsClosed();
    connection.injectedDelay();

    logger.debug("execute: {}", sql);

    String trimmedSql = sql.trim();

    if (trimmedSql.length() >= 20
        && trimmedSql.toLowerCase().startsWith("set-sf-property"))
    {
      // deprecated: sfsql
      executeSetProperty(sql);
      return false;
    }

    SFBaseResultSet sfResultSet;
    try
    {
      sfResultSet = sfStatement.execute(sql, parameterBindings,
                                        SFStatement.CallingMethod.EXECUTE);
      sfResultSet.setSession(this.connection.getSfSession());
      if (resultSet != null)
      {
        openResultSets.add(resultSet);
      }
      resultSet = new SnowflakeResultSetV1(sfResultSet, this);
      queryID = sfResultSet.getQueryId();

      // Legacy behavior treats update counts as result sets for single-
      // statement execute, so we only treat update counts as update counts
      // if JDBC_EXECUTE_RETURN_COUNT_FOR_DML is set, or if a statement
      // is multi-statement
      if (!sfResultSet.getStatementType().isGenerateResultSet() &&
          (connection.getSfSession().isExecuteReturnCountForDML() ||
           sfStatement.hasChildren()))
      {
        updateCount = ResultUtil.calculateUpdateCount(sfResultSet);
        if (resultSet != null)
        {
          openResultSets.add(resultSet);
        }
        resultSet = null;
        return false;
      }

      updateCount = NO_UPDATES;
      return true;
    }
    catch (SFException ex)
    {
      throw new SnowflakeSQLException(ex.getCause(),
                                      ex.getSqlState(), ex.getVendorCode(), ex.getParams());
    }
  }
172274
public int count(String sql, Object[] params) {
				
		int rowCount = 0;
		try{
			Map<String, Object> resultMap = null;
			if (params == null || params.length == 0) {
				resultMap = getProxy().queryForMap(sql);
			} else {
				resultMap = getProxy().queryForMap(sql, params);
			}
			Iterator<Map.Entry<String, Object>> it = resultMap.entrySet().iterator();
			if(it.hasNext()){
				Map.Entry<String, Object> entry = it.next();
				rowCount = ((Long)entry.getValue()).intValue();
			}
		}catch(EmptyResultDataAccessException e){
			
		}
		
		
		return rowCount;
	}
213249
int update(Config config, Connection conn, String sql, Object... paras) throws SQLException {
		PreparedStatement pst = conn.prepareStatement(sql);
		config.dialect.fillStatement(pst, paras);
		int result = pst.executeUpdate();
		DbKit.close(pst);
		return result;
	}
249851
static ResultSet executeStatement(SQL sql) throws SQLException {
    try (SqlSession session = sqlSessionFactory.openSession(true)) {
      try (Connection conn = session.getConnection()) {
        try (Statement stmt = conn.createStatement()) {
          return stmt.executeQuery(sql.toString());
        }
      }
    }
  }
1297502
public static Long executeForGeneratedKey(Connection conn, String sql, Map<String, Object> paramMap) throws SQLException {
		final NamedSql namedSql = new NamedSql(sql, paramMap);
		return executeForGeneratedKey(conn, namedSql.getSql(), namedSql.getParams());
	}
274011
public String queryString(String sql, Object... params) throws SQLException {
		return query(sql, new StringHandler(), params);
	}
491463
@Override
	public boolean execute(final LineReader reader, final String[] parts, final SqlConfig sqlConfig,
			final Properties props) {
		PrintWriter writer = reader.getTerminal().writer();

		String tableNamePattern = parts.length > 1 ? parts[parts.length - 1] : "%";

		try {
			Connection conn = sqlConfig.getConnectionSupplier().getConnection();
			DatabaseMetaData md = conn.getMetaData();

			List<Map<String, String>> columns = new ArrayList<>();
			Map<String, Integer> labelLength = new HashMap<>();
			for (String label : DESC_COLUMN_LABELS) {
				labelLength.put(label, label.length());
			}
			try (ResultSet rs = md.getColumns(conn.getCatalog(), conn.getSchema(), tableNamePattern, null)) {
				while (rs.next()) {
					Map<String, String> column = new HashMap<>();
					for (String label : DESC_COLUMN_LABELS) {
						final String value = StringUtils.defaultString(rs.getString(label));
						column.put(label, value);
						labelLength.compute(
								label,
								(k, v) -> v == null ? getByteLength(value)
										: v.compareTo(getByteLength(value)) >= 0 ? v : getByteLength(value));
					}
					columns.add(column);
				}
			}

			// ラベル
			writer.print("-");
			for (String label : DESC_COLUMN_LABELS) {
				writer.print(StringUtils.rightPad("", labelLength.get(label), "-"));
				writer.print("-");
			}
			writer.println();
			writer.print("|");
			for (String label : DESC_COLUMN_LABELS) {
				writer.print(StringUtils.rightPad(label, labelLength.get(label)));
				writer.print("|");
			}
			writer.println();
			// カラムデータ
			String tableName = null;
			boolean breakFlag = false;
			for (Map<String, String> column : columns) {
				if (tableName == null || !tableName.equalsIgnoreCase(column.get("TABLE_NAME"))) {
					tableName = column.get("TABLE_NAME");
					breakFlag = true;
				}
				if (breakFlag) {
					writer.print("-");
					for (String label : DESC_COLUMN_LABELS) {
						writer.print(StringUtils.rightPad("", labelLength.get(label), "-"));
						writer.print("-");
					}
					writer.println();
					breakFlag = false;
				}

				writer.print("|");
				for (String label : DESC_COLUMN_LABELS) {
					String val = column.get(label);
					if (StringUtils.isNumeric(val)) {
						writer.print(StringUtils.leftPad(val, labelLength.get(label)));
					} else {
						writer.print(StringUtils.rightPad(val, labelLength.get(label)));
					}
					writer.print("|");
				}
				writer.println();
			}
			writer.print("-");
			for (String label : DESC_COLUMN_LABELS) {
				writer.print(StringUtils.rightPad("", labelLength.get(label), "-"));
				writer.print("-");
			}
			writer.println();
		} catch (SQLException ex) {
			ex.printStackTrace();
		}
		writer.flush();

		return true;
	}
490826
static <T> List<T> executeOraBlock(Connection connection, String sql, Class<T> clazz, List<SqlParam> sqlParams) throws SQLException {
		String cursorParam = null;
		List<T> list = new ArrayList<T>();
		//boolean autoCommitOrig = connection.getAutoCommit();
		//if (autoCommitOrig == true) {
		//	connection.setAutoCommit(false); // to able to read from temp-tables
		//}

		CallableStatement stmt = null;
		ResultSet resultSet = null;
		try {
			stmt = connection.prepareCall(sql);
			cursorParam = stmtAssignSqlParams(stmt, sqlParams);
			boolean hasRs = stmt.execute();
			if (cursorParam != null) {
				resultSet = (ResultSet) stmt.getObject(cursorParam);
				list = resultSetToList(resultSet, clazz);
			}
		} finally {
			try { if (resultSet != null) resultSet.close(); } catch (Exception e) {logger.error("Cannot close resultSet", e);};
			//if (autoCommitOrig == true)
			//	connection.setAutoCommit(autoCommitOrig);
			try { if (stmt != null) stmt.close(); } catch (Exception e) {logger.error("Cannot close statement", e);};
		}
		return list;
	}
683211
public List<Entity> findBySql(String sql, Object... params) throws SQLException {
		String selectKeyword = StrUtil.subPre(sql.trim(), 6).toLowerCase();
		if(false == "select".equals(selectKeyword)){
			sql = "SELECT * FROM " + this.tableName + " " + sql;
		}
		return db.query(sql, new EntityListHandler(), params);
	}