Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem Connecting to DB2 by COM.ibm.db2.jdbc.net. DB2Driver

 
VijayRawat Rawat
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am getting problem when making connection to DB2, which resides on mainframe. I am using COM.ibm.db2.jdbc.net.DB2Driver driver

I am using this piece of code
try {
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newInstance();
System.out.println("Class COM.ibm.db2.jdbc.net.DB2Driver loaded");
String url = "jdbc : db2://server: port/database";
System.out.println("Getting a connection");
con = DriverManager.getConnection(url, "user", "password"); (hangs up)
System.out.println("Got connection");
} catch (Exception ex) {
System.out.println("Exception : " +ex.getMessage());
ex.printStackTrace();
}
It successfully loads driver but when it tries to get connection, it hangs up.

Can some body tell me where I am going wrong

Thanks and Regards
Vijay Rawat

[ December 29, 2005: Message edited by: VijayRawat Rawat ]

[ December 29, 2005: Message edited by: VijayRawat Rawat ]
[ December 29, 2005: Message edited by: VijayRawat Rawat ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly you should look at using a DataSource, unless this is just a stand-alone application.

To debug JDBC connection problems, I tend to use SquirrelSQL to determine the settings (driver, url, login details) and then transfer these settings to the application. It is a lot easier to change the details there than having to recompile and run each group of settings. I'd make sure you can ping that IP first.

Also, please edit your post and remove any sensitive data. I'm not sure we need your database username and password to be displayed.

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic