Reputation: 109
I am using Apache Ignite driver for ODBC in order to query my cache(my application is wrriten in 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
SQLGetConnectAttr(dbc, SQL_COPT_SS_CONNECTION_DEAD,...)
But AFAIK I can't call it with ignite driver API.
Is there any other standrad way to check current conncetion state?
Upvotes: 0
Views: 627
Reputation: 463
Actually, SQL_ATTR_CONNECTION_DEAD
is supported by Ignite and should work. 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.
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.
Upvotes: 1
Reputation: 736
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.
Upvotes: 0
Reputation: 184
I believe that it would not be possible with ODBC. Most attributes are not supported https://apacheignite.readme.io/v2.1/docs/conformance
You should use the ignite C++ instead. If you already built your project, then you might have a lot of refactoring https://apacheignite-cpp.readme.io/docs/getting-started
Good luck
Upvotes: 0