I want to find DB2 port in windows, please help. Some information:
- DB2 v 9.7 Personal Edition - new/fresh install
- netstat command does not list db2 port.
- db2 entry missing was missing in system32\drivers\etc\services file so, made an entry - "db2c_DB2 50000/tcp"
- able to start db2 using control center and create tables and insert rows
- able to start db2 using CLP and perform opertaions
Actually, I'm trying to connect to DB2 using "jdbc:db2://127.0.0.1:50000/TEST" as connect URL from Java but, I get an error: "Exception java.net.ConnectException: Error opening socket to server /127.0.0.1 on port 50,000 with message: Connection ref used: connect. ERRORCODE=-4499, SQLSTATE=08001"
I find that DB is up and running but, not listening on port 50000, though mentioned in services file. So, db2 is listening on some other port but,
- what's the port it's using?
- why it's not using port #50000 as mentioned in services file?
- why netstat command is not listing db2 service and port information?
Thanks much in advance.
Firstly make sure TCP comms is set on,
You can check if it's not using the default port,
Should get a line like this,
The above would should a port number if it was not set to default port, as you can see my config is default (=50000)
Since you are able to start DB2 and connect to a local database from Control Center (via the CLI driver using shared memory), one or more of the following issues may be preventing JDBC connections, which communicate over TCP/IP.
Changes to either the DB2 registry (via DB2SET) or the DBM configuration require DB2 to be stopped and started before they take effect.
You can't do it from Java. You need to find out from the dbadmin or the DB/2 configuration itself. Your item (3) accomplished nothing really: the 'services' file is indicative only, or for use by some clients; it doesn't tell DB/2 what to do. Only DB/2's own configuration does that.
First things first, installation displayed an error at the end. I do not remember the error but, I could not start db2. So, googled and found a simple solution and it worked. I could start and perform db operations as can be seen in OP. But, hunt to find port number was still on. After further googling, I found that value for "SVCENAME" was blank, then I updated the parameter and entered port # in services file. Even then, it didn't help. As a last resort, just re-installed DB2 and everything worked fine. Just a note: A successful installation will have value for "SVCENAME" in configuration and db2 will make an entry in services file for service name and port.
It seems that when the Service Name DBM parameter is blank, it means that TCP connections are not possible. It is not an problem if you are going to use DB2 locally, by accessing the database from the same machine.
In order to configure TCP connections, you have to follow the steps described in the other answers. However, having an instance without Service Name does not indicate a problem.
There is a discussion about issue in this page: http://groups.google.com/group/comp.databases.ibm-db2/browse_thread/thread/a515365a5d04af81
Because JDBC uses a TCP connection you do really need to change the configuration of your instance in order to connect to the database.