I have to make DB2 connection in java using port number. Is there any command in DB2 or any way that can get the DB2 port number?
I have not used the default port 50000 while making DB2 connection as this port can be changed during DB2 installation. Please suggest any DB2 command or any other alternative.
As a server processing TCP/IP connection requests for DRDA SQL applications, Db2 uses a server port or the well-known port, 446, which is used for relational database communications.
If enabled, the default DB2 instance will be assigned a default port of TCP:50000 for TCP/IP communication. TCP:50000 is a widely known DB2 port, so this port assignment should be changed.
The Db2 command line processor is a program that runs under z/OS UNIX System Services. You can use the Db2 command line processor to execute SQL statements, bind DBRMs that are stored in HFS files into packages, call stored procedures, and perform XML schema repository operations.
On the Windows DB2 server, open a DB2 Command Window and execute the command
db2 get database manager configuration | findstr /i svce
This should provide some output like:
TCP/IP Service name (SVCENAME) = db2c_DB2 SSL service name (SSL_SVCENAME) =
SVCENAME is the port that DB2 is listening on. To resolve this name to an actual port number, you need to refer to the services file, which is located at %SystemRoot%\system32\drivers\etc\services
.
Go to DB2 command prompt.
Issue the command to get the db2 instance
Command : db2 get instance
Issue the command to find the TCP/IP service name
Command : db2 get dbm cfg | grep SVCE
Example
db2 get dbm cfg | grep SVCE
TCP/IP Service name (SVCENAME) = db2c_db2inst9 The TCP/IP service name is "db2c_db2inst9"
Use the TCP/IP service name to find the port number in the /etc/services file
Command : grep TCP/IPservicename /etc/services
Change TCP/IPservicename with the current service name.
Example
grep db2c_db2inst9 /etc/services
db2c_db2inst9 50090/tcp
The DB2 instance is running on the port number 50090
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With