IBM Support

How to query MySQL Community Edition data source using Federation Server through JDBC driver

Question & Answer


Question

How to query MySQL community edition data source using Federation Server through JDBC driver?

Cause

Customers want to use Federation server connect to MySQL community edition server through JDBC driver.

Answer

To configure a federation to access MySQL Community Server data source through JDBC wrapper, you need to provide the information about the data source and objects that you want to access. Then create wrapper, server, user mapping and nickname about the tables on remote MySQL Community Server data source.

Before you begin

Download the JDBC connector mariadb-java-client-x.x.x.jar file from the MariaDB official site, and put it in your local path. MySQL community edition server now use the same JDBC connector with MariaDB.

1. Enable Federation server and restart Db2.

# db2 update dbm cfg using federated YES

# db2stop force

# db2start

2. Test the connection to the MySQL Community Server data source and verify the service is started correctly.

telnet <MySQL_community_server_ip> <port>
If the connection is successful, you receive the following similar output from the command.

# telnet 9.30.230.97 3306
Trying 9.30.230.97...
Connected to 9.30.230.97.

If the connection fails, you will receive an error, please check the MySQL community service status.

3. Create wrapper, server, user mapping, nickname, and query the nickname. For MySQL Community Server you need to specify the server type “MYSQL_CE” while you creating the server.

# connect to testdb

# create wrapper "wrapper1" library 'libdb2rcjdbc.so' options(db2_fenced 'y')

# create server server1 type mysql_ce wrapper "wrapper1" options (driver_class  'org.mariadb.jdbc.driver' ,driver_package  '/home/hotellnx122/haijun/fed_mysqljdbc0228/mariadb-java-client-2.4.0.jar', url  'jdbc:mariadb://bye1.fyre.ibm.com:3306/mysql' )

# create user mapping for user server server1 options(remote_authid 'root',remote_password 'passw0rd!')
# create nickname nk1 for server1."tb1"

# select * from nk1

col_1

--------------------------

1970-11-23-12.12.12.000000

1999-12-31-12.12.12.000000

  2 record(s) selected.

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m500000008PkvAAE","label":"Federation"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
06 August 2020

UID

ibm11126635