简体   繁体   English

检查连接状态-Ignite的C ++ odbc驱动程序

[英]Check connection state - C++ odbc driver for Ignite

I am using Apache Ignite driver for ODBC in order to query my cache(my application is wrriten in C++). 我正在为ODBC使用Apache Ignite驱动程序以便查询我的缓存(我的应用程序在C ++中被写入)。

As part of implementing it I need a way to know if a connection is still open in order to use it. 作为实现的一部分,我需要一种方法来知道连接是否仍处于打开状态才能使用它。

I know that for Windows API the solution is to use this 我知道对于Windows API,解决方案是使用此

SQLGetConnectAttr(dbc, SQL_COPT_SS_CONNECTION_DEAD,...)

But AFAIK I can't call it with ignite driver API. 但是AFAIK我不能使用ignite驱动程序API来调用它。

Is there any other standrad way to check current conncetion state? 还有其他标准方法可以检查当前的特许状态吗?

Actually, SQL_ATTR_CONNECTION_DEAD is supported by Ignite and should work. 实际上,Ignite支持SQL_ATTR_CONNECTION_DEAD ,并且应该可以正常工作。 Here is the actual page . 这是实际页面 But make sure that this is what you want because the SQL_ATTR_CONNECTION_DEAD checks the most recent state of the connection, and might not be the current connection state. 但是请确保这是您想要的,因为SQL_ATTR_CONNECTION_DEAD检查连接的最新状态,并且可能不是当前的连接状态。

Also, pay attention that since 2.5 Ignite's ODBC driver supports failover mechanism and tries to automatically restore connection, once the current server node is down. 另外,请注意,由于2.5 Ignite的ODBC驱动程序支持故障转移机制,并在当前服务器节点关闭后尝试自动恢复连接。

I believe that it would not be possible with ODBC. 我相信使用ODBC是不可能的。 Most attributes are not supported https://apacheignite.readme.io/v2.1/docs/conformance 不支持大多数属性https://apacheignite.readme.io/v2.1/docs/conformance

You should use the ignite C++ instead. 您应该改用ignite C ++。 If you already built your project, then you might have a lot of refactoring https://apacheignite-cpp.readme.io/docs/getting-started 如果您已经构建了项目,那么可能会有很多重构https://apacheignite-cpp.readme.io/docs/getting-started

Good luck 祝好运

I think that you can do a simple check like next or similar: 我认为您可以进行下一个或类似的简单检查:

    SQLCHAR req[] = "SELECT 1";

    SQLRETURN ret = SQLExecDirect(stmt, req, SQL_NTS);

    if (!SQL_SUCCEEDED(ret))
        //conection failed

It should work with Ignite to check the connection. 它应该与Ignite一起使用以检查连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM