If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Enabling tcpip

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-27-11, 04:37
abhay_bc abhay_bc is offline
Registered User
 
Join Date: Jul 2011
Posts: 5
Enabling tcpip

Hi I am sure this is not a new one, and I am also going through the forum to find out answer to this one. Still if you can help .. Thanks.

I've setup db2 on linux and would like to connect to it from my java application on a different machine ( windows ) using the jdbc driver com.ibm.db2.jcc.DB2Driver.

I've read that we need to enable db2 to provide service over tcpip, and I've done these steps :
1) edit /etc/services to add this
server1 49000/tcp
2) db2 connect to sample
3) db2 "update database manager configuration using svcename server1"
4) db2stop
5) db2start
6) db2set DB2COMM=tcpip
7) db2stop
8) db2start
9) db2 "get database manager configuration"

Step (9) shows me that db2 tcp/ip service is set up in the configuration.

Also, "netstat -anp | grep 49000" shows me this :

tcp 0 0 0.0.0.0:49000 0.0.0.0:* LISTEN 9622/db2sysc 0

But I am not able to connect to this db2 instance from my java app, it says no route to the host.

Here is my connection configuration in Java :

dburl="jdbc:db2://server.ip.address:49000/sample:"
dbuser="db2inst1"
dbpassword="password"
dbenvironment="sample"
driverClass="com.ibm.db2.jcc.DB2Driver"

where, server.ip.address represents my internal server ip address.

To check connectivity of the server on that port, I also tried
telnet server.ip.address 49000

Even that indicates no connectivity to the server on that port.
I am able to otherwise ping to that server from my windows machine.

What does this mean ? is tcp/ip for db2 setup correctly ?

THANKS
Reply With Quote
  #2 (permalink)  
Old 07-27-11, 05:17
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
the setup seems ok
can you display the complete message : sql message could indicate some hint
try to execute the program locally from the db-server..
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 07-27-11, 05:22
abhay_bc abhay_bc is offline
Registered User
 
Join Date: Jul 2011
Posts: 5
it will take some time to do this on the server itself, but I did a quick test using telnet on that server and looks like it is running a service on that port.



[root@localhost ~]# telnet 10.10.93.50 49000
Trying 10.10.93.50...
Connected to 10.10.93.50 (10.10.93.50).
Escape character is '^]'.

So I'm sure it will work there.

From window's machine, this is what I get :

X:\>telnet 10.10.93.50 49000
Connecting To 10.10.93.50...Could not open connection to the host, on port 49000: Connect failed

X:\>ping 10.10.93.50

Pinging 10.10.93.50 with 32 bytes of data:

Reply from 10.10.93.50: bytes=32 time=37ms TTL=63
Reply from 10.10.93.50: bytes=32 time=1ms TTL=63
Reply from 10.10.93.50: bytes=32 time<1ms TTL=63

Ping statistics for 10.10.93.50:
Packets: Sent = 3, Received = 3, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 37ms, Average = 12ms

SQL Error is :

Db connection error: DbConnectionException: [ibm][db2][jcc][t4][2043][11550] Exception java.net.NoRouteToHostException: Error opening socket to server /10.10.93.50 on port 49,000 with message: No route to host: connect.

Last edited by abhay_bc; 07-27-11 at 05:31. Reason: Added sql error
Reply With Quote
  #4 (permalink)  
Old 07-27-11, 06:33
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
seems, there may be problem with the particular port #. Have you verified with your network guys that the particular port is open. You can also try changing the servicename by assigning it to a different port, say 50001 or 50002, if those ports are currently not used.
__________________

Jayanta Datta
DB2 UDB DBA
IBM India, Global Delivery
New Delhi
Reply With Quote
  #5 (permalink)  
Old 07-27-11, 06:38
abhay_bc abhay_bc is offline
Registered User
 
Join Date: Jul 2011
Posts: 5
I am checking if there is anything like firewall sitting between the two machines that's blocking that port.

As far as the port availability is concerned, the port is available since it is not configured for any other service in /etc/services. And also db2start did not give any error indicating that port is already in use by some other service.
Reply With Quote
  #6 (permalink)  
Old 07-27-11, 07:13
JAYANTA_DATTA JAYANTA_DATTA is offline
Registered User
 
Join Date: Oct 2004
Location: DELHI INDIA
Posts: 336
the database services at the server will continue to run even if you haven't assigned any port for the db2 services. the SVCENAME parameter & the TCP⁄IP port are used by the DBM to await communications from remote clients or local clients. So you can see at the DB server commands like DB2START etc are working good, but if the port is not opened for other remote clients, then from remote systems, you may not be able to access the database process on the target server.

Keep us posted with your finding.
__________________

Jayanta Datta
DB2 UDB DBA
IBM India, Global Delivery
New Delhi
Reply With Quote
  #7 (permalink)  
Old 07-27-11, 08:47
abhay_bc abhay_bc is offline
Registered User
 
Join Date: Jul 2011
Posts: 5
Resolved

Guys, I got it resolved ! The problem was that the local firewall on linux ( iptables ) was blocking access to this port. I added a line in there to allow incoming connections on 49000, and restarted the iptables service. That took care of it !

Thanks for all your help and time.
Reply With Quote
Reply

Tags
configuration, db2, jdbc, remote, tcpip

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On