Thursday, December 15, 2011

SQL1336N The remote host "serverX" was not found

Exception in thread "main" COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] SQL1336N The remote host "serverX" was not found.

at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Connection.connect(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Connection.(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)

If you get above error, one possible reason could be the alias name used could be pointing to wrong database server.

Connection con=DriverManager.getConnection("jdbc:db2:ALIASNAME","username","password");

In my case ALIASNAME was required to point serverX but it was referring to serverY. I knew the solution but I did not know how to do it. I asked my database administrator (DBA) to have a look at the issue. What he told me is, he has to uncatalog and catalog it with the correct server.

Truly speaking I don’t know the meaning of these terms "uncatalog and catalog", I asked him let me know the solution as this issue may arise in future too. He told as i am a programmer, i cannot do the task which a DBA can do... Is it really?

So dear friends I may disappoint you and I apologize for that. But if this is the case with yours please contact with your database administrator.