Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connecting to db2 using net driver

 
niranjan pulipati
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic