Question & Answer
Question
Cause
Customers want to use Federation server connect to MariaDB through JDBC driver?
Answer
Before you begin
Download the jdbc connector mariadb-java-client-x.x.x.jar file from MariaDB official site, and put it in your local path.
1. Enable Federation server and restart Db2.
# db2 update dbm cfg using federated YES
# db2stop force
# db2start
2. Test the connection to the MariaDB data source and verify the service is started correctly.
telnet <MariaDB_server_ip> <port>
If the connection is successful, you receive the following similar output from the command.
# telnet 9.30.140.105 3306
Trying 9.30.140.105...
Connected to 9.30.140.105.
If the connection fails, you will receive an error, please check the MariaDB service status.
3. Create wrapper, server, user mapping, nickname, and query the nickname.
# connect to testdb
# create wrapper "wrapper1" library 'libdb2rcjdbc.so' options(db2_fenced 'y')
# create server server1 type mariadb wrapper "wrapper1" options (driver_class 'org.mariadb.jdbc.driver' ,driver_package '/home/hotellnx116/haijs/fed_mysqljdbc0228/mariadb-java-client-2.4.0.jar', url 'jdbc:mariadb://9.30.140.105:3306/mysql')
# create user mapping for user server server1 options(remote_authid 'mysql',remote_password 'passw0rd')
# create nickname nk1 for server1."test1"
# select * from nk1
-------------------- ----------
1 hai
3 hai
4 hai
5 hai
Was this topic helpful?
Document Information
Modified date:
06 August 2020
UID
ibm11126623