0

I am using following java application to connect db2 database for localhost and code is:

String jdbcClassName="com.ibm.db2.jcc.DB2Driver";
String url="jdbc:db2://localhost:50000/sample";
String user="admin";
String password="admin";
try {
    //Load class into memory
    Class.forName(jdbcClassName);
    //Establish connection
    connection = DriverManager.getConnection(url, user, password);
    stmt = connection.createStatement();
}
catch (SQLException e) {
    e.printStackTrace();
}

The problem is that when application and db2 is running on the same machine, then it is working, but if db2 database is on another machine then it is not working. I am using ip in my url which is:

String url="jdbc:db2://192.168.1.68:50000/sample";

And it's giving the following error:

com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][3.59.81] Exception java.net.ConnectException: Error opening socket to server /192.168.1.64 on port 50,000 with message: Connection timed out: connect. ERRORCODE=-4499, SQLSTATE=08001

How can I connect to the database remotely?

3
  • U tried telnet 192.168.1.68 50000 ?? Commented Dec 22, 2017 at 12:37
  • Is DB2 actually listening on port 50000 on IP address 192.168.1.68, the error suggests it isn't. Commented Dec 22, 2017 at 12:56
  • 1
    Firewall? Different IP address? Commented Dec 22, 2017 at 13:01

1 Answer 1

0

Check if your private or public network firewall is on ?? If it is on then instead of doing it off make an inbound rule and then try to connect it with DB2 database from another system.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.