Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Oct 2011
    Posts
    9

    Unanswered: 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.

  2. #2
    Join Date
    Nov 2007
    Posts
    265
    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

  3. #3
    Join Date
    Oct 2011
    Posts
    9
    Thanks for the reply.


    I am trying to connect from Eclipse.

  4. #4
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    What is the exact java statement that is failing and what is the exact error you are getting?

    Andy

  5. #5
    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

  6. #6
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    On the server <HostName>, what port is the DB2 instance running on?

    Andy

  7. #7
    Join Date
    Oct 2011
    Posts
    9
    Andy,

    Its running on port 1209

  8. #8
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by girishmb79 View Post
    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.
    ............................

  9. #9
    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. #10
    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 12:25.

  11. #11
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Using DSN entry should work. Port 1209 is very unusual for DB2. What OS is the server and what DB2 version?

    Andy

  12. #12
    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?

  13. #13
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by girishmb79 View Post
    I am using db2jcc.jar and db2jcc_license_cu.jar in RAD/Eclipse
    Quote Originally Posted by girishmb79 View Post
    DB2 is on Mainframe
    You'll need db2jcc_license_cisuz.jar to connect to System z.

    http://www.dbforums.com/db2/854783-m...e-posting.html

  14. #14
    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.

  15. #15
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •