Search code examples
postgresqlubuntuodbcpoco-librariesunixodbc

SQLCloseCursor exception while working with POCO ODBC


I have installed unixOdbc on my Ubuntu PC. I have configured DSN 'mydsn' and it works just fine with isql.

> isql mydsn
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> insert into users values('1', 'user', 'password');
SQLRowCount returns 1

It means postgres odbc driver and data source are installed and configured properly. I couldn't connect isql before everything was configured.

If I am trying to execute the same statement with Poco::ODBC it fails with the exception.

E [2016-06-25 13:41:48.117] Application  {3}: ODBC handle exception: SQLCloseCursor(): Connection:Not applicable
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = 200
Native Error Code = 0
[nxDC[rvrMngrIvldcro tt

Here is my code

using Poco::Data::ODBC::Connector;
...
Connector::registerConnector();
_pool = new SessionPool(Connector::KEY, "DSN=mydsn;", size, size);
Session session(_pool->get());

session << "insert into users values('2', 'user', 'password');", now;

I tried to google SQLCloseCursor exception but it gives me a lot of irrelevant results. I haven't tried to debug (break points and so) this yet.

Any suggestion of where to start?


Solution

  • I have upgrade ubuntu 14 to ubuntu 16.04 and the problem disapperd. It looks like some bug in unixODBC 2.24 while working with Postgres 9.3.