Has someone used Type 4 jdbc driver to connect to DB2 8.1 database on AIX 5 ?
Code
public class DBTest {
public static void main(String[] args) {
try {
// load the DB2 Driver
Class.forName("com.ibm.db2.jcc.DB2Driver");
// establish a connection to DB2
System.out.println("1");
Connection db2Conn =
DriverManager.getConnection(
"jdbc:db2://10.80.17.29:50000/DBNAME","db2inst2","db2admin");
System.out.println("2");
Statement st = db2Conn.createStatement();
System.out.println("3");
String query =
" SELECT CB_CARDHOLDER_NO "+ " FROM CP_CRDTBL";
// execute the query
ResultSet resultSet = st.executeQuery(query);
System.out.println("4");
while (resultSet.next()) {
String jobType = resultSet.getString(1);
System.out.println(jobType + "\t" + jobType);
}
resultSet.close();
st.close();
db2Conn.close();
}
catch (ClassNotFoundException cnfe) {
cnfe.printStackTrace();
}
catch (Exception sqle) {
sqle.printStackTrace();
}
}
I am getting the following error trace.
com.ibm.db2.jcc.b.DisconnectException: A communication error has been detected.
Communication protocol being used: Reply.fill(). Communication API being used: I
nputStream.read(). Location where the error was detected: insufficient data. Com
munication function detecting the error: *. Protocol specific error codes(s) TCP
/IP SOCKETS
at com.ibm.db2.jcc.a.a.a(a.java:428)
at com.ibm.db2.jcc.a.ab.b(ab.java:202)
at com.ibm.db2.jcc.a.ab.c(ab.java:222)
at com.ibm.db2.jcc.a.ab.c(ab.java:337)
at com.ibm.db2.jcc.a.ab.v(ab.java:1447)
at com.ibm.db2.jcc.a.bb.a(bb.java:39)
at com.ibm.db2.jcc.a.b.e(b.java:1232)
at com.ibm.db2.jcc.a.b.b(b.java:1147)
at com.ibm.db2.jcc.a.b.q(b.java:931)
at com.ibm.db2.jcc.a.b.a(b.java:702)
at com.ibm.db2.jcc.a.b.<init>(b.java:305)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:162)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at DBTest.main(DBTest.java:15)
Are there any configurations to be done at server side ?
-
Db2 8.1 on AIX 5 and JDBC connection problem (1 messages)
- Posted by: p p
- Posted on: January 17 2005 08:20 EST
Threaded Messages (1)
- Db2 8.1 on AIX 5 and JDBC connection problem by p p on January 17 2005 23:46 EST
-
Db2 8.1 on AIX 5 and JDBC connection problem[ Go to top ]
- Posted by: p p
- Posted on: January 17 2005 23:46 EST
- in response to p p
got the solution
The problem was with port at which the instance was running.
There were 2 instances running on Db2 , one at 50000 , the other at 50001.
Found the same from a file named services in /etc directory.