aspose file tools*
The moose likes JDBC and the fly likes Problem Connecting to DB2 by COM.ibm.db2.jdbc.net. DB2Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem Connecting to DB2 by COM.ibm.db2.jdbc.net. DB2Driver" Watch "Problem Connecting to DB2 by COM.ibm.db2.jdbc.net. DB2Driver" New topic
Author

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

VijayRawat Rawat
Greenhorn

Joined: Aug 19, 2004
Posts: 9
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

Joined: Mar 06, 2001
Posts: 13459

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem Connecting to DB2 by COM.ibm.db2.jdbc.net. DB2Driver