Question & Answer
Question
How to query Apache Cassandra using Db2 Federation through ODBC driver?
Answer
Before you begin
Enable Federation feature and restart Db2 to make it effective:
$ db2 update dbm cfg using federated YES
Pre-Configuration on Linux, Unix
-
Make sure the required ODBC drivers are installed correctly:
ls sqllib/federation/odbc/lib/ FOcsndr*.so
-
Make sure the data source is accessible to the Federation server:
$ telnet cassandradb1.fyre.ibm.com 9042 Trying 9.30.143.51... Connected to cassandradb1.fyre.ibm.com. Escape character is '^]'.
- Create the server, wrapper, user mapping, and nickname:
$ CREATE WRAPPER odbc options(DB2_FENCED 'Y', module '~/sqllib/federation/odbc/lib/libodbc.so') $ CREATE SERVER server_odbc_cassandra TYPE cassandra VERSION 5.0.0 WRAPPER odbc options(HOST 'cassandradb1.fyre.ibm.com', CUSTOMIZED_ODBC_ATTRIBUTES ; PortNumber=9042;KeyspaceName= ‘mykeyspace’); $ CREATE USER MAPPING FOR PUBLIC SERVER server_odbc_cassandra OPTIONS( REMOTE_AUTHID <user>, REMOTE_PASSWORD <password> ); $ CREATE NICKNAME nickname nk_test123 for server_odbc_cassandra."mykeyspace"."test123";
- Query the nickname that you created:
$ select count(*) from nk_ test123 1 ----------- 3 1 record(s) selected.
[{"Type":"MASTER","Line of Business":{"code":"","label":""},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSCAVPX","label":"Federated Server"},"ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":""}]
Was this topic helpful?
Document Information
More support for:
Federated Server
Document number:
7233194
Modified date:
21 May 2025
UID
ibm17233194
Manage My Notification Subscriptions