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.

 
Go Back  dBforums > Database Server Software > DB2 > error connecting db2-class not found exception

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-07-12, 12:06
madhu9124 madhu9124 is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
error connecting db2-class not found exception

Hi,
I tried connecting jsp file developed using eclipse to DB2 database using apache tomcat server.I get error as:java.lang.ClassNotFoundException: COM.ibm.db2.jcc.DB2Driver.
Please help me in solving this issue.

Thank You
Madhu
Reply With Quote
  #2 (permalink)  
Old 02-07-12, 13:30
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Do you have the following, executed before you connect?

Code:
Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
Andy
Reply With Quote
  #3 (permalink)  
Old 02-08-12, 13:28
madhu9124 madhu9124 is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
com.ibm.db2.jcc.c.DisconnectException error

Hi,
After using the code -Class.forName("com.ibm.db2.jcc.DB2Driver").newInst ance();.The class exception error has been solved but,
Now i am getting another error-

com.ibm.db2.jcc.c.DisconnectException: [ibm][db2][jcc][t4][2030][11211] A communication error has been detected. Communication protocol being used: TCP/IP.
Communication API being used: SOCKETS. Location where the error was detected: Reply.fill().
Communication function detecting the error: InputStream.read(). Protocol specific error codes Insufficient data, * , 0. Message: null.

Please help me in solving this error.

Thank You
Madhu
Reply With Quote
  #4 (permalink)  
Old 02-08-12, 13:32
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Can you post the java code that contains, in order, all the JDBC calls, and which one is getting the error?

Andy
Reply With Quote
  #5 (permalink)  
Old 02-08-12, 13:39
madhu9124 madhu9124 is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
java code

<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.sql.*" %>
<%
Connection con = null;
Statement stmt = null;
ResultSet rs = null;



String name=request.getParameter("Donor_Name");

String emailid=request.getParameter("Email_id");

String password=request.getParameter("Password");

String occupation=request.getParameter("Occupation");


String address=request.getParameter("Address");

String state=request.getParameter("State");

String city=request.getParameter("City");


String area=request.getParameter("Area");








String bloodgroup=request.getParameter("Blood_group");







try{


Class.forName("COM.ibm.db2.jcc.DB2Driver ");

con = DriverManager.getConnection("jdbc:db2://localhost:8080/IBM_TGMC","","");


stmt=con.createStatement();



stmt.executeUpdate("insert into USER_REGISTRATION( DONAR NAME, EMAIL ID,PASSWORD,OCCUPATION,DOB,ADDRESS,STATE,CITY,AREA ,CONTACT_NO,BLOOD GROUP,HEIGHT,WEIGHT,LAST DONATED) values('"+name+"','"+emailid+"','"+password+"','"+ occupation+"','"+address+"','"+state+"','"+city+"' ,'"+area+"','"+bloodgroup+"')");
con.close();
out.println("Data is successfully inserted into database");
}
catch(Exception e){
System.out.println(e);

}
%>
Reply With Quote
  #6 (permalink)  
Old 02-08-12, 13:53
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Are you sure your DB2 instance uses port 8080? Quite an unusual choice.
Reply With Quote
  #7 (permalink)  
Old 02-08-12, 14:03
madhu9124 madhu9124 is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
com.ibm.db2.jcc.c.SqlException

Hi,
8080 is the apache tomcat server port no..
The error seems to have been solved after i relaunched the eclipse.
Now i have another error:
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704

Please help me in solving this error

Thank You
Madhu
Reply With Quote
  #8 (permalink)  
Old 02-08-12, 14:17
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Code:
SQL0204N  "<name>" is an undefined name.

Explanation:

This error is caused by one of the following:

*  The object identified by "<name>" is not defined in the database.
*  The data partition identified by "<name>" is not defined on the
   table.
*  A data type is being used. This error can occur for the following
   reasons:
   *  If "<name>" is qualified, then a data type with this name does not
      exist in the database.
   *  If "<name>" is unqualified, then the user's path does not contain
      the schema to which the desired data type belongs.
   *  The data type does not exist in the database with a create
      timestamp earlier than the time the package was bound (applies to
      static statements).
   *  If the data type is in the UNDER clause of a CREATE TYPE
      statement, the type name may be the same as the type being
      defined, which is not valid.

*  A function is being referenced in one of:
   *  a DROP FUNCTION statement
   *  a COMMENT ON FUNCTION statement
   *  the SOURCE clause of a CREATE FUNCTION statement

      If "<name>" is qualified, then the function does not exist. If
      "<name>" is unqualified, then a function of this name does not
      exist in any schema of the current path.



      Note that a function cannot be sourced on the COALESCE,
      DBPARTITIONNUM, GREATEST, HASHEDVALUE, LEAST, MAX (scalar), MIN
      (scalar), NULLIF, RID, NVL, RAISE_ERROR, TYPE_ID, TYPE_NAME,
      TYPE_SCHEMA, or VALUE built-in functions.

*  The element named "<name>" is used on the right side of the UNDER
   clause in CREATE SECURITY LABEL COMPONENT statement but has not yet
   been defined as being ROOT or being UNDER some other element
*  The security label component element named "<name>" has not yet been
   defined.
*  One of the following scalar functions specified a security policy
   identified by "<name>" which is not defined in the database.
   *  SECLABEL
   *  SECLABEL_TO_CHAR
   *  SECLABEL_BY_NAME

This return code can be generated for any type of database object.

Federated system users: the object identified by "<name>" is not defined
in the database or "<name>" is not a nickname in a DROP NICKNAME
statement.

Some data sources do not provide the appropriate values for "<name>". In
these cases, the message token will have the following format:
"OBJECT:<data source> TABLE/VIEW", indicating that the actual value for
the specified data source is unknown.

The statement cannot be processed.

User response:

Ensure that the object name (including any required qualifiers) is
correctly specified in the SQL statement and it exists. If the name
refers to a data partition, query the catalog table
SYSCAT.DATAPARTITIONS to find the names of all the data partitions for a
table. For missing data type or function in SOURCE clause, it may be
that the object does not exist, OR it may be that the object does exist
in some schema, but the schema is not present in your path.

For the CREATE or ALTER SECURITY LABEL COMPONENT statement, make sure
that each element specified as a reference element value for positioning
the location of a new element value already exists in the security label
component.

For the CREATE SECURITY LABEL COMPONENT statement, make sure that each
element is specified as either ROOT or as the child in an UNDER clause
before specifying it as the parent in an UNDER clause.

For the scalar functions SECLABEL, SECLABEL_TO_CHAR or SECLABEL_BY_NAME,
ensure that a valid security policy was specified for the argument
security-policy-name.

Federated system users: if the statement is DROP NICKNAME, make sure the
object is actually a nickname. The object might not exist in the
federated database or at the data source. Verify the existence of the
federated database objects (if any) and the data source objects (if
any).

sqlcode: -0204

 sqlstate: 42704
All of this is available in the DB2 manuals.

Andy
Reply With Quote
  #9 (permalink)  
Old 02-08-12, 14:26
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by madhu9124 View Post
8080 is the apache tomcat server port no..
Clearly, it should be the DB2 instance port number. I think you should start reading manuals.
Reply With Quote
  #10 (permalink)  
Old 03-31-12, 00:30
yogesh29010 yogesh29010 is offline
Registered User
 
Join Date: Mar 2012
Posts: 3
hi,
I have tried both of the urls:
Class.forName("com.ibm.db2.jcc.DB2Driver").newInst ance();
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver").ne wInstance();

but each time it generates errors..
please help me

javax.servlet.ServletException: java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
org.apache.jasper****ntime.PageContextImpl.doHandl ePageException(PageContextImpl.java:911)
org.apache.jasper****ntime.PageContextImpl.handleP ageException(PageContextImpl.java:840)
org.apache.jsp.klkl_jsp._jspService(klkl_jsp.java: 124)
org.apache.jasper****ntime.HttpJspBase.service(Htt pJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet .java:668)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:433)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet .java:668)


root cause

java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
java.lang.Class.forNameImpl(Native Method)
java.lang.Class.forName(Class.java:139)
org.apache.jsp.klkl_jsp._jspService(klkl_jsp.java: 84)
org.apache.jasper****ntime.HttpJspBase.service(Htt pJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet .java:668)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:433)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet .java:668)
Reply With Quote
  #11 (permalink)  
Old 03-31-12, 06:55
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Do you have db2jcc.jar / db2jcc4.jar in your CLASSPATH ?
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #12 (permalink)  
Old 03-31-12, 09:05
yogesh29010 yogesh29010 is offline
Registered User
 
Join Date: Mar 2012
Posts: 3
thanx for reply.. i have resolved that problem but now another error is there..
please help


i have defined all class paths.. but getting this error when displaying db2 table contents on browser.
(i guess problem is arising due to "sqlj.zip/sqlj4.zip" folders provided with jdbc download, but dont know what to do with this )
please reply
.................................................. ...........................................
javax.servlet.ServletException: java.sql.SQLException: No suitable driver
org.apache.jasper****ntime.PageContextImpl.doHandl ePageException(PageContextImpl.java:911)
org.apache.jasper****ntime.PageContextImpl.handleP ageException(PageContextImpl.java:840)
org.apache.jsp.dudy_jsp._jspService(dudy_jsp.java: 130)
org.apache.jasper****ntime.HttpJspBase.service(Htt pJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet .java:668)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:433)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet .java:668)




is it fine ? (see my screenshot )
Attached Thumbnails
error connecting db2-class not found exception-screenhunter_14-mar.-31-18.44.jpg  

Last edited by yogesh29010; 03-31-12 at 09:21.
Reply With Quote
  #13 (permalink)  
Old 03-31-12, 11:28
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by yogesh29010 View Post
javax.servlet.ServletException: java.sql.SQLException: No suitable driver
This most likely means that your JDBC URL scheme does not match the driver that you load. Since you didn't show either, I can only wish you good luck with further troubleshooting.
Reply With Quote
  #14 (permalink)  
Old 03-31-12, 11:59
yogesh29010 yogesh29010 is offline
Registered User
 
Join Date: Mar 2012
Posts: 3
it worked when i have re-started WAS, dont know why i need to re-start server every time.

thanks a lot for replying, and one more problem i am facing:
I have imported a netbeans web project (.war) in eclipse indigo, it gives lots of error in html code, though it was full functional at netbeans.
when i run it on server it gives error:
this status has children statuses... help me.. how to overcome this.
i have many .JS and .CSS and folders in Web Content directory in my project..

please reply..
thank
Reply With Quote
  #15 (permalink)  
Old 03-31-12, 16:02
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
well, this is not a java/netbeans/eclipse forum. Find one to post this question

=
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On