aspose file tools
The moose likes JDBC and Relational Databases and the fly likes connecting to db2 using net driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Groovy Fundamentals video training course this week in the Groovy forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "connecting to db2 using net driver" Watch "connecting to db2 using net driver" New topic
Author

connecting to db2 using net driver

niranjan pulipati
Greenhorn

Joined: Jul 04, 2001
Posts: 4
I wrote a program to connect to a db2 database on a system named Niranjan and database name is SAMPLE.
the program is
import java.sql.*;
import java.io.*;

public class netdb {

public static void main(String s[]) {
String db="SAMPLE";
String user="db2admin";
String pass="db2admin";
String conn = "jdbc:db2://NIRANJAN:3456/SAMPLE";
try{
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
Connection Conn = DriverManager.getConnection (conn,user,pass);
System.out.println("Connection uccess");
Statement SQLStatement = Conn.createStatement();
String Query ="SELECT * FROM EMPLOYEE";
ResultSet SQLResult = SQLStatement.executeQuery(Query);
while(SQLResult.next()) {
System.out.println(SQLResult.getString(1));
}
} catch(Exception e) {
System.out.println(e);
}
}

}
This program is giving an error
"COM.ibm.db2.jdbc.net.DB2Exception: [IBM][JDBC Driver] CLI0616E Error opening socket. SQLSTATE=08S01"
Plese Help me to get rid of this problem..
Niranjan

Julio Lopez
Greenhorn

Joined: Nov 14, 2000
Posts: 28
Instead of using "NIRANJAN" in the URL I would try using the IP address instead.
String conn = "jdbc:db2://NIRANJAN:3456/SAMPLE";
Julio Lopez
M-Group Systems
sach rao
Greenhorn

Joined: May 10, 2001
Posts: 3
Originally posted by niranjan pulipati:
I wrote a program to connect to a db2 database on a system named Niranjan and database name is SAMPLE.
the program is
import java.sql.*;
import java.io.*;

public class netdb {

public static void main(String s[]) {
String db="SAMPLE";
String user="db2admin";
String pass="db2admin";
String conn = "jdbc:db2://NIRANJAN:3456/SAMPLE";
try{
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
Connection Conn = DriverManager.getConnection (conn,user,pass);
System.out.println("Connection uccess");
Statement SQLStatement = Conn.createStatement();
String Query ="SELECT * FROM EMPLOYEE";
ResultSet SQLResult = SQLStatement.executeQuery(Query);
while(SQLResult.next()) {
System.out.println(SQLResult.getString(1));
}
} catch(Exception e) {
System.out.println(e);
}
}

}
This program is giving an error
"COM.ibm.db2.jdbc.net.DB2Exception: [IBM][JDBC Driver] CLI0616E Error opening socket. SQLSTATE=08S01"
Plese Help me to get rid of this problem..
Niranjan


sach rao
Greenhorn

Joined: May 10, 2001
Posts: 3
Is your Database instance started or Is it listening at port no 3456 ?
Sach
Originally posted by Julio Lopez:
Instead of using "NIRANJAN" in the URL I would try using the IP address instead.
String conn = "jdbc:db2://NIRANJAN:3456/SAMPLE";
Julio Lopez
M-Group Systems

Sadaf Ahmed
Greenhorn

Joined: Mar 19, 2004
Posts: 3
Hi,
I am facing exactly the same problem here. Could you please tell me how to overcome this if you did?

Thanks,
Sadaf
Priya Dhir
Greenhorn

Joined: Apr 29, 2005
Posts: 1
Hi,
I am getting the following error when trying to connect to DB2.

COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01


the code is :
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
Connection con =
DriverManager.getConnection(
"jdbc b2://INIDCP01BDC01:50000/GRPSREF",
"db2adminla",
"db2adminla");


Any idea what the possible problem could actually be ?


Thanks
[ April 29, 2005: Message edited by: Priya Dhir ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: connecting to db2 using net driver