pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: karthik kumar <karthikkumar.db2dba@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Carto ODBC_FDW issue "ERROR: Connecting to driver" from PG to DB2
Date: Mon, 9 Apr 2018 13:19:05 -0700
Message-ID: <2aef0ab7-8854-978a-aae0-7e3cf6214c79@aklaver.com> (raw)
In-Reply-To: <CADbTQ2a9Y4-3dQCOq7BG8juf2cyZvm7tAhW_XTpdJv1n5c-QPA@mail.gmail.com>
References: <CADbTQ2a9Y4-3dQCOq7BG8juf2cyZvm7tAhW_XTpdJv1n5c-QPA@mail.gmail.com>

On 04/09/2018 01:01 PM, karthik kumar wrote:
> Hi Guru's,
> 
> I am trying to access few table present in DB2 LUW from postgres database.
> All commands work fine, however when I try to select data from table it 
> throws error:
> 
> pg@a92a3741d40e:~/odbc_fdw$ psql -d postgres
> psql (10.1)
> Type "help" for help.
> 
> postgres=# create extension odbc_fdw;
> CREATE EXTENSION
> 
> postgres=# CREATE SERVER odbc_db2 FOREIGN DATA WRAPPER odbc_fdw OPTIONS 
> (dsn 'SAMPLE');
> CREATE SERVER
> 
> 
> 
> postgres=# CREATE USER MAPPING FOR pg SERVER odbc_db2 OPTIONS (odbc_UID  
> 'db2inst1', odbc_PWD 'db2inst1');

Assuming using this:

https://github.com/ZhengYang/odbc_fdw

I believe that should be username and password per above link:

"CREATE USER MAPPING FOR postgres
	SERVER odbc_server
	OPTIONS (username 'root', password '');
"

> CREATE USER MAPPING
> 
> postgres=#
> postgres=# CREATE FOREIGN TABLE
> postgres-#   odbc_testt (
> postgres(#     id integer
> postgres(#   )
> postgres-#   SERVER odbc_db2
> postgres-#   OPTIONS (
> postgres(#     odbc_database 'SAMPLE',

Is the above the database name as well as the DSN name?

> postgres(#     odbc_schema 'db2inst1',
> postgres(#     sql_query 'select x from `db2inst1`.`TESTT`',

Is the column name case sensitive, because below it shows up as X?

I would try without the sql_query and sql_count queries as they are 
optional.

> postgres(#     sql_count 'select count(id) from `db2inst1`.`dblist`'
> postgres(#   );
> CREATE FOREIGN TABLE
> 
> postgres=# select * from odbc_testt;
> ERROR:  Connecting to driver
> 
> 
> 
> pg@a92a3741d40e:~/odbc_fdw$ isql -v SAMPLE db2inst1 db2inst1
> +---------------------------------------+
> | Connected!                            |
> |                                       |
> | sql-statement                         |
> | help [tablename]                      |
> | quit                                  |
> |                                       |
> +---------------------------------------+
> SQL> select * from testt;
> +------------+
> | X          |
> +------------+
> | 1          |
> +------------+
> SQLRowCount returns -1
> 1 rows fetched
> SQL> quit
> 
> 
> root@a92a3741d40e:/home/pg# cat /etc/odbc.ini
> [SAMPLE]
> Description = DB2 remote SAMPLE Database
> Driver=/home/db2inst1/sqllib/lib64/libdb2.so
> SERVERNAME=MYDB2
> UID=db2inst1
> PWD=db2inst1
> port=50000
> 
> 
> Thanks,
> Karthik.


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (17+ messages)  latest in thread

Message-ID: <2aef0ab7-8854-978a-aae0-7e3cf6214c79@aklaver.com>
Permalink:  ../2aef0ab7-8854-978a-aae0-7e3cf6214c79@aklaver.com/
Also on:    postgresql.org/message-id/2aef0ab7-8854-978a-aae0-7e3cf6214c79@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, karthikkumar.db2dba@gmail.com
  Subject: Re: Carto ODBC_FDW issue "ERROR: Connecting to driver" from PG to DB2
  In-Reply-To: <2aef0ab7-8854-978a-aae0-7e3cf6214c79@aklaver.com>
  References: <CADbTQ2a9Y4-3dQCOq7BG8juf2cyZvm7tAhW_XTpdJv1n5c-QPA@mail.gmail.com> <2aef0ab7-8854-978a-aae0-7e3cf6214c79@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox