Assistance in troubleshooting connecting to Vertica via odbc from a cpp application
Hi,
I'm building an application in cpp that should connect to a vertica database.
I've installed the odbc driver on the dev machine and defined a DSN named "Vertica". it works fine via isql, but the following code results in "Could not connect to database":
const char* dsnName = "Vertica";
const char* userID = "<omitted>";
const char* passwd = "<omitted>";
ret = SQLConnect(hdlDbc, (SQLCHAR*)dsnName,SQL_NTS,(SQLCHAR*)userID,SQL_NTS,(SQLCHAR*)passwd, SQL_NTS);
if(!SQL_SUCCEEDED(ret)) {
printf("Could not connect to database.\n");
}
Upon debug, the ret variable is found to be -1.
Is there any way to get a more verbose response?
Thanks
0
Comments
Hi Tomer,
Since you're using isql to test the DSN, I assume your client code is on Linux? Have you conifgured a vertica.ini file? You can add logging settings in the vertica.ini file to get a better idea of what is happening when you client attempts to connect. Please see Additional Parameter Settings in the documentation.
I've setup the odbc.ini, odbcinst.ini and vertica.ini files as per the instructions and set an environment variable VERTICAINI. I found out how to catch the error message (good idea to add it to the connection instructions BTW...).
When invoking the following code:
This is the driver response:
I've checked the odbc.ini file and these two properties appear (stars mask the actual values for security reasons):
This is vertica.ini:
Ok, thanks to vertica-forums I found the problem. I was linking to libverticaodbc and I should've been lining to libodbc.