| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

10-26-11, 16:51
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
|
Not able to connect to db2 from java
|
|
Hi All,
I am not able to connect to DB2 database from java, no matter what driver I use. I am using (db2java.zip and db2jcc.jar) or (db2jcc_license_cu.jar and db2jcc.jar and db2jcc_license_cisuz.jar)
I either get
"No suitable driver found" for For Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
OR
Class.forName("com.ibm.db2.jcc.DB2Driver");
"Exception in thread "main" com.ibm.db2.jcc.am.yn: [jcc][t4][2030][11211][3.57.82] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream. Error location: Reply.fill(). Message: Insufficient data. ERRORCODE=-4499, SQLSTATE=08001"
Thank you for your help in Advance.
|
|

10-26-11, 18:05
|
|
Registered User
|
|
Join Date: Nov 2007
Posts: 248
|
|
Not sure if this helps -- but we recently set up java for 8.2 64-bit, here are the steps that I wrote down from then.. maybe you can double check if this applies to your server, good luck!
1. yum install libXp-1.0.0-8.1.el5.i386
rpm -ivh IBMJava2-AMD64-142-SDK-1.4.2-13.9.x86_64.rpm
rmp -ivh IBMJava2-AMD64-142-JRE-1.4.2-13.9.x86_64.rpm
2. Make sure JDK_PATH is set to /opt/IBMJava2-amd64-142
db2 get dbm cfg | grep JDK_PATH
If not, then set it with the update dbm command --
db2 update dbm cfg USING JDK_PATH /opt/IBMJava2-amd64-142
db2stop
db2start
3. Go to /etc/profile and add the following lines above the line that says
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
export PATH=$PATH:/opt/IBMJava2-amd64-142/jre/bin
export JAVA_HOME=/opt/IBMJava2-amd64-142
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip:/$JAVA_HOME/lib
4. Add a path to the shared libraries in /etc/ld.so.conf
vi /etc/ld.so.conf
Add the following line-- /opt/IBMJava2-amd64-142/jre/bin
Give the command ldconfig for changes to take effect
exit out / log back in to test
|
|

10-27-11, 09:26
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
|
|
Thanks for the reply.
I am trying to connect from Eclipse.
|
|

10-27-11, 10:31
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
What is the exact java statement that is failing and what is the exact error you are getting?
Andy
|
|

10-27-11, 10:39
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
I am using db2jcc.jar and db2jcc_license_cu.jar in RAD/Eclipse
Java version - 1.5
Class.forName("com.ibm.db2.jcc.DB2Driver");
String url ="jdbc:db2://<HostName>:1209/<DB Name>";
Connection con = DriverManager.getConnection(url,"UID","PW");
I am getting error in the last line (Connetion con)
com.ibm.db2.jcc.am.yn: [jcc][t4][2030][11211][3.57.82] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream. Error location: Reply.fill(). Message: Insufficient data. ERRORCODE=-4499, SQLSTATE=08001
|
|

10-27-11, 10:53
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
On the server <HostName>, what port is the DB2 instance running on?
Andy
|
|

10-27-11, 11:13
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
Andy,
Its running on port 1209
|
|

10-27-11, 11:17
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Quote:
Originally Posted by girishmb79
ERRORCODE=-4499, SQLSTATE=08001
|
Quote:
|
Originally Posted by the fine manual
-4499 text-from-getMessage
Explanation: A fatal error occurred that resulted in a disconnect from the data source. The existing connection has become unusable.
User response: Call SQLException.getMessage to retrieve specific information about the problem.
|
............................
|
|

10-27-11, 11:20
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
I did that and I got the same error infor
Message()..[jcc][t4][2030][11211][3.57.82] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream. Error location: Reply.fill(). Message: Insufficient data. ERRORCODE=-4499, SQLSTATE=08001
|
|

10-27-11, 11:21
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
Is there a way for me to connect to DB2 database using DSN entry ? or ODBC connection
|
Last edited by girishmb79; 10-27-11 at 11:25.
|

10-27-11, 11:45
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
Using DSN entry should work. Port 1209 is very unusual for DB2. What OS is the server and what DB2 version?
Andy
|
|

10-27-11, 12:08
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
DB2 is on Mainframe. Not sure about the db2 vesion, I guess its the laterst version.
Can you help me how to connect using DSN in JAVA?
|
|

10-27-11, 12:50
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Quote:
Originally Posted by girishmb79
I am using db2jcc.jar and db2jcc_license_cu.jar in RAD/Eclipse
|
Quote:
Originally Posted by girishmb79
DB2 is on Mainframe
|
You'll need db2jcc_license_cisuz.jar to connect to System z.
Must Read before posting
|
|

10-27-11, 13:34
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 9
|
|
Sorry, I am new to this.
I do have db2jcc_license_cisuz.jar included in the class path.
If I can't succeed in connecting to DB2 by above method, can some onehelp me how to connect using DSN in JAVA?
Any pointers would be appreciated.
|
|

10-27-11, 14:10
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
You'll need to:
- install DB2 client
- install DB2 connect
- catalog the database (CATALOG DATABASE and CATALOG DCS database commands)
- catalog the datasource (CATALOG ODBC DATA SOURCE)
- use the Type 2 ("app") driver (COM.ibm.db2.jdbc.app.DB2Driver) to connect
Should be enough keywords for you to research further.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|