• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sql::SQLString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sql::SQLString的典型用法代码示例。如果您正苦于以下问题:C++ SQLString类的具体用法?C++ SQLString怎么用?C++ SQLString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SQLString类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: if

/* {{{ MySQL_Connection::getClientOption() -I- */
void
MySQL_Connection::getClientOption(const sql::SQLString & optionName, void * optionValue)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::getClientOption");
	if (!optionName.compare("metadataUseInfoSchema")) {
		*(static_cast<bool *>(optionValue)) = intern->metadata_use_info_schema;
	} else if (!optionName.compare("defaultStatementResultType")) {
		*(static_cast<int *>(optionValue)) = intern->defaultStatementResultType;
	} else if (!optionName.compare("defaultPreparedStatementResultType")) {
		*(static_cast<int *>(optionValue)) = intern->defaultPreparedStatementResultType;
	} else if (!optionName.compare("multiByteMinLength")) {
		MY_CHARSET_INFO cs;
		proxy->get_character_set_info(&cs);
		*(static_cast<int *>(optionValue)) = cs.mbminlen;
	} else if (!optionName.compare("multiByteMaxLength")) {
		MY_CHARSET_INFO cs;
		proxy->get_character_set_info(&cs);
		*(static_cast<int *>(optionValue)) = cs.mbmaxlen;
	/* mysql_get_option() was added in mysql 5.7.3 version */
	} else if ( proxy->get_server_version() >= 50703 ) {
		try {
			if (GET_CONN_OPTION(optionName, optionValue, intOptions)) {
				return;
			} else if (GET_CONN_OPTION(optionName, optionValue, booleanOptions)) {
				return;
			} else if (GET_CONN_OPTION(optionName, optionValue, stringOptions)) {
				return;
			}
		} catch (sql::SQLUnsupportedOptionException& e) {
			CPP_ERR_FMT("Unsupported option : %d:(%s) %s", proxy->errNo(), proxy->sqlstate().c_str(), proxy->error().c_str());
			throw e;
		}
	}
}
开发者ID:vaddanak,项目名称:challenges,代码行数:35,代码来源:mysql_connection.cpp


示例2: CPP_ENTER_WL

/* {{{ MySQL_Connection::getClientOption() -I- */
void
MySQL_Connection::getClientOption(const sql::SQLString & optionName, void * optionValue)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::getClientOption");
	if (!optionName.compare("metadataUseInfoSchema")) {
		*(static_cast<bool *>(optionValue)) = intern->metadata_use_info_schema;
	} else if (!optionName.compare("defaultStatementResultType")) {
		*(static_cast<int *>(optionValue)) = intern->defaultStatementResultType;
	} else if (!optionName.compare("defaultPreparedStatementResultType")) {
		*(static_cast<int *>(optionValue)) = intern->defaultPreparedStatementResultType;
	} else if (!optionName.compare("characterSetResults")) {
		*(static_cast<sql::SQLString **>(optionValue)) = new sql::SQLString(getSessionVariable("characterSetResults"));
	}
}
开发者ID:Beirdo,项目名称:mysql-connector-cpp,代码行数:15,代码来源:mysql_connection.cpp


示例3: CPP_ENTER_WL

/* {{{ MySQL_Connection::getClientOption() -I- */
sql::SQLString
MySQL_Connection::getClientOption(const sql::SQLString & optionName)
{
	CPP_ENTER_WL(intern->logger, "MySQL_Connection::getClientOption");

	if (!optionName.compare("characterSetResults")) {
		return sql::SQLString(getSessionVariable("character_set_results"));
	} else if (!optionName.compare("characterSetDirectory")) {
		MY_CHARSET_INFO cs;
		proxy->get_character_set_info(&cs);
		return cs.dir ? sql::SQLString(cs.dir) : "";
	} else if ( proxy->get_server_version() >= 50703 ) {
		const char* optionValue= NULL;
		if (GET_CONN_OPTION(optionName, &optionValue, stringOptions)) {
			return optionValue ? sql::SQLString(optionValue) : "";
		}
	}
	return "";
}
开发者ID:vaddanak,项目名称:challenges,代码行数:20,代码来源:mysql_connection.cpp


示例4: checkValid

        /* {{{ MySQL_ArtResultSet::findColumn() -I- */
        uint32_t
        MySQL_ArtResultSet::findColumn(const sql::SQLString& columnLabel) const
        {
            CPP_ENTER("MySQL_ArtResultSet::columnLabel");
            checkValid();

            boost::scoped_array< char > upstring(sql::mysql::util::utf8_strup(columnLabel.c_str(), 0));

            FieldNameIndexMap::const_iterator iter = field_name_to_index_map.find(upstring.get());

            if (iter == field_name_to_index_map.end()) {
                return 0;
            }
            /* findColumn returns 1-based indexes */
            return iter->second + 1;
        }
开发者ID:AaronZhangL,项目名称:CC,代码行数:17,代码来源:mysql_art_resultset.cpp


示例5: get_connection_option

bool get_connection_option(const sql::SQLString optionName,
								void *optionValue,
								const String2IntMap options_map[],
								size_t map_size,
								boost::shared_ptr< NativeAPI::NativeConnectionWrapper > &proxy)
{
	for (size_t i = 0; i < map_size; ++i) {
		if (!optionName.compare(options_map[i].key)) {
			try {
				proxy->get_option(static_cast<sql::mysql::MySQL_Connection_Options>(options_map[i].value), optionValue);
			} catch (sql::InvalidArgumentException& e) {
				std::string errorOption(options_map[i].key);
				throw ::sql::SQLUnsupportedOptionException(e.what(), errorOption);
			}
			return true;
		}
	}
	return false;
}
开发者ID:vaddanak,项目名称:challenges,代码行数:19,代码来源:mysql_connection.cpp


示例6: setHost

/* {{{ MySQL_Uri::setHost() -I- */
void MySQL_Uri::setHost(const sql::SQLString &h)
{
  setProtocol(NativeAPI::PROTOCOL_TCP);
  host= h.c_str();
}
开发者ID:Gitju,项目名称:mysql-connector-cpp,代码行数:6,代码来源:mysql_uri.cpp


示例7: parseUri

/* URI formats tcp://[host]:port/schema
               unix://socket
               pipe://named_pipe
 */
bool parseUri(const sql::SQLString & str, MySQL_Uri& uri)
{
  if (!str.compare(0, sizeof(MYURI_SOCKET_PREFIX) - 1, MYURI_SOCKET_PREFIX))
  {
    uri.setSocket(str.substr(sizeof(MYURI_SOCKET_PREFIX) - 1, sql::SQLString::npos));

    return true;
  }

  if (!str.compare(0, sizeof(MYURI_PIPE_PREFIX) - 1 , MYURI_PIPE_PREFIX))
  {
    uri.setPipe(str.substr(sizeof(MYURI_PIPE_PREFIX) - 1, sql::SQLString::npos));

    return true;
  }

  sql::SQLString host;
  size_t start_sep, end_sep;

  /* i wonder how did it work with "- 1"*/
  if (!str.compare(0, sizeof(MYURI_TCP_PREFIX) - 1, MYURI_TCP_PREFIX) )
  {
    host= str.substr(sizeof(MYURI_TCP_PREFIX) - 1, sql::SQLString::npos);
  }
  else
  {
    /* allowing to have port and schema specified even w/out protocol
       specifier("tcp://") */
    host= str.c_str();
  }

  if (host[0] == MYURI_HOST_BEGIN)
  {
    end_sep= host.find(MYURI_HOST_END);

    /* No closing ] after [*/
    if (end_sep == sql::SQLString::npos)
    {
      return false;
    }

    uri.setHost(host.substr(1, end_sep - 1));
    /* Cutting host to continue w/ port and schema reading */
    host= host.substr(end_sep + 1);
  }

  /* Looking where schema part begins */
  start_sep = host.find('/');

  if (start_sep != sql::SQLString::npos)
  {
    if ((host.length() - start_sep) > 1/*Slash*/)
    {
      uri.setSchema(host.substr(start_sep + 1, host.length() - start_sep - 1));
    }

    host= host.substr(0, start_sep);
  }
  else
  {
    uri.setSchema("");
  }

  /* Looking where port part begins*/
  start_sep = host.find_last_of(':', sql::SQLString::npos);

  if (start_sep != sql::SQLString::npos)
  {
    uri.setPort(atoi(host.substr(start_sep + 1, sql::SQLString::npos).c_str()));
    host = host.substr(0, start_sep);
  }
  else
  {
    uri.setPort(DEFAULT_TCP_PORT);
  }

  /* If host was enclosed in [], it has been already set, and "host" variable is
     empty */
  if (host.length() > 0)
  {
    uri.setHost(host);
  }

  return true;
}
开发者ID:Gitju,项目名称:mysql-connector-cpp,代码行数:89,代码来源:mysql_uri.cpp


示例8: setPipe

/* {{{ MySQL_Uri::setPipe() -I- */
void MySQL_Uri::setPipe(const sql::SQLString &p)
{
  setProtocol(NativeAPI::PROTOCOL_PIPE);
  host= p.c_str();
}
开发者ID:Gitju,项目名称:mysql-connector-cpp,代码行数:6,代码来源:mysql_uri.cpp


示例9: setSocket

/* {{{ MySQL_Uri::setSocket() -I- */
void MySQL_Uri::setSocket(const sql::SQLString &s)
{
  setProtocol(NativeAPI::PROTOCOL_SOCKET);
  host= s.c_str();
}
开发者ID:Gitju,项目名称:mysql-connector-cpp,代码行数:6,代码来源:mysql_uri.cpp


示例10:

/* {{{ MySQL_NativeStatementWrapper::prepare() */
int
MySQL_NativeStatementWrapper::prepare(const ::sql::SQLString & stmt_str)
{
    return api->stmt_prepare(stmt, stmt_str.c_str(), stmt_str.length());
}
开发者ID:ssidko,项目名称:WorkProjects,代码行数:6,代码来源:mysql_native_statement_wrapper.cpp



注:本文中的sql::SQLString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sqldatabase::StatementPtr类代码示例发布时间:2022-05-31
下一篇:
C++ sqf::Parameters类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap