Skip to Content
0

How to utilize connection pooling in odbc client for connecting to SAP Hana?

Oct 10, 2017 at 03:31 PM

159

avatar image
Former Member

Hi

I have an SAP Hana instance running. I want to connect to it using ODBC driver packaged along with Hana client zip.

I tried following the steps as mentioned here, but I am getting an error.

_result = SQLSetEnvAttr(SQL_NULL_HENV, SQL_ATTR_CONNECTION_POOLING, (SQLPOINTER)SQL_CP_ONE_PER_DRIVER, 0);
printf("\nresult = %d\n", _result);

When I run this, I get result as -2.

How do I get started with connection pooling? Does Sap Hana support ODBC connection pooling? If so then can I get a document that I can follow, or a sample code?

Thanks
Suman

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Tom Slee
Oct 11, 2017 at 04:44 PM
2

Hi Suman,

I checked with HANA Client engineering. ODBC Connection pooling is implemented by the ODBC Driver Manager (Microsoft and unixODBC), which is why it is not documented as part of the Client interface. https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetenvattr-function lists SQL_ATTR_CONNECTION_POOLING as an ODBC 3.8 feature, so your driver manager would have to support that version.

This code snippet (not standalone and not mine) may provide some guidance:

struct EnvAttrPair EnvAttributes[] = {
  {SQL_ATTR_CONNECTION_POOLING, SQL_CP_OFF, SQL_SUCCESS},
  {SQL_ATTR_CONNECTION_POOLING, SQL_CP_ONE_PER_DRIVER, SQL_SUCCESS},
  {SQL_ATTR_CONNECTION_POOLING, SQL_CP_ONE_PER_HENV, SQL_SUCCESS},
  {SQL_ATTR_CP_MATCH, SQL_CP_STRICT_MATCH, SQL_SUCCESS},
  {SQL_ATTR_CP_MATCH, SQL_CP_RELAXED_MATCH, SQL_SUCCESS},
  {SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC3, SQL_SUCCESS},
  {SQL_ATTR_ODBC_VERSION, SQL_OV_ODBC2, SQL_SUCCESS},
  {SQL_ATTR_OUTPUT_NTS, SQL_TRUE, SQL_SUCCESS}
};

TEST_P(ODBCEnvAttrUnitTest, testSetGetEnvAttr)
{
  retcode = SQLSetEnvAttr(henv, GetParam().attr,(SQLPOINTER) (SQLLEN) (GetParam().value), 0);
  if (retcode == SQL_SUCCESS) {
    SQLINTEGER value;
    retcode = SQLGetEnvAttr(henv, GetParam().attr, &value, 0, NULL);
  }
}
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Tom,

Thank you for the reply.

So is it the case that connection pooling is not supported by the HANA Odbc driver packaged along with the provided tar (hdb_client_linux_x86_64.tgz) ?

Also, another question that I have is, how long does a connection remain valid? And how do I modify the related attribute for my needs?

0
Denys van Kempen
Oct 11, 2017 at 09:19 AM
1

Hi Suman,

The SAP HANA Client Interface Programming Reference documents ODBC Connection Properties but SQL_ATTR_CONNECTION_POOLING is not one of them.

https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.02/en-US/7cab593774474f2f8db335710b2f5c50.html

From the same reference, connection pooling is only mentioned for ADO.NET.

https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.02/en-US/469db8536d6110148e81a8891f6080b5.html

Regards,

Denys / SAP HANA Academy

Subscribe to our YouTube Channel
Join us on LinkedIn
Follow us on Twitter
Github code samples
Facebook
Google+

Share
10 |10000 characters needed characters left characters exceeded