Search code examples
databasejdbcdb2db2-connect

How to connect to remote db2 database with CL tools?


How to connect to remote db2 database with util db2advis or similar? I can connect with jdbc:db2://ip:port/dbname. How this should be converted in terms of Db2 commandline tools to db name "db2advis -d database_name"?


Solution

  • DB2 utilities such as db2look, db2expln, and db2advis require an entry for the remote instance in the local DB2 node directory, and an entry for the remote database in the local DB2 database directory. The commands involved with this are db2 "LIST NODE DIRECTORY", db2 "LIST DB DIRECTORY", db2 "CATALOG NODE" (or "CATALOG TCPIP NODE"), and db2 "CATALOG DATABASE". If those commands do not work, you may not have a full DB2 client installed, since JDBC connections can connect with only a couple of JAR files. If the db2ilist command cannot be found on the entire local server, you definitely don't have a full DB2 client installed. If db2ilist is there, but running it produces no results, then a client instance hasn't been created yet. Otherwise, you'll need to source the the ./sqllib/db2profile script located immediately beneath the home directory of the DB2 client instance owner.