Mysql 连接器 C++ 无缓冲结果集 C++
Mysql Connector C++ Unbuffered ResultSet C++
我有一个 table 可以保存大量数据。
我想把所有的数据都取出来,一个一个处理。
根据此处的文档:
https://dev.mysql.com/doc/connector-cpp/en/connector-cpp-examples-results.html
The API for fetching result sets is identical for (simple) statements
and prepared statements. If your query returns one result set, use
sql::Statement::executeQuery() or
sql::PreparedStatement::executeQuery() to run your query. Both methods
return sql::ResultSet objects. By default, Connector/C++ buffers all
result sets on the client to support cursors.
它说默认情况下它会缓冲客户端上的所有结果集。
我怎样才能禁用它?
在语句中,您可以定义结果集的类型。使用 TYPE_FORWARD_ONLY
会导致未缓冲的结果集,如 mysql release notes:
中所定义
... Implemented getResultSetType() and setResultSetType() for
Statement. Uses TYPE_FORWARD_ONLY, which means unbuffered result set
and TYPE_SCROLL_INSENSITIVE, which means buffered result set.
希望对您有所帮助。
我有一个 table 可以保存大量数据。 我想把所有的数据都取出来,一个一个处理。
根据此处的文档: https://dev.mysql.com/doc/connector-cpp/en/connector-cpp-examples-results.html
The API for fetching result sets is identical for (simple) statements and prepared statements. If your query returns one result set, use sql::Statement::executeQuery() or sql::PreparedStatement::executeQuery() to run your query. Both methods return sql::ResultSet objects. By default, Connector/C++ buffers all result sets on the client to support cursors.
它说默认情况下它会缓冲客户端上的所有结果集。 我怎样才能禁用它?
在语句中,您可以定义结果集的类型。使用 TYPE_FORWARD_ONLY
会导致未缓冲的结果集,如 mysql release notes:
... Implemented getResultSetType() and setResultSetType() for Statement. Uses TYPE_FORWARD_ONLY, which means unbuffered result set and TYPE_SCROLL_INSENSITIVE, which means buffered result set.
希望对您有所帮助。