class not found exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • menmysql
    New Member
    • Mar 2007
    • 53

    class not found exception

    hi

    i am using mysql as database while connecting to database using jsp i am getting the following exception


    "java.lang.Clas sNotFoundExcept ion:com.mysql.j dbc.Driver"


    can any one tell wha tis the actual problem



    regards
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    Did you retype this on the site, or did you copy and paste? There is a space in the middle of the word Driver - you may have mistakenly typed an extra space when typing the import statement.

    Comment

    • dmjpro
      Top Contributor
      • Jan 2007
      • 2476

      #3
      did u include the JDBC library?????

      Comment

      • sicarie
        Recognized Expert Specialist
        • Nov 2006
        • 4677

        #4
        Originally posted by menmysql
        hi

        i am using mysql as database while connecting to database using jsp i am getting the following exception

        "java.lang.Clas sNotFoundExcept ion:com.mysql.j dbc.Driver"

        can any one tell wha tis the actual problem

        regards
        My guess would be that the problem lies in your 1) classpath, or 2) declaration.

        Did you include the JDBC driver in your classpath, or attach it to your project? If so, can wee see your declaration (the classforname, etc...)?

        Comment

        • menmysql
          New Member
          • Mar 2007
          • 53

          #5
          i copyed the exception what i got from my jsp page thats why


          Originally posted by Ganon11
          Did you retype this on the site, or did you copy and paste? There is a space in the middle of the word Driver - you may have mistakenly typed an extra space when typing the import statement.

          Comment

          • menmysql
            New Member
            • Mar 2007
            • 53

            #6
            thanks for your reply,

            i downloaded mysql connector/j from mysql.com ,i copied the .jar file in to ./tomcat 5.0/common/lib and i set path at environment variables. i tryed at two different systems. in one system which is upgraded from mysql 4.0.17 to 5.0 and webserver is tomcat 5x, at this system i am getting java.sql.SQLExc eption: Communication link failure: Bad handshake


            then i went to my friends place and i freshely installed java 6.0, tomcat 6x, mysql 5.0 and mysql connector/j 5.0 and i set path as above i mentiond. but this time i am getting different exception that is "java.lang.Clas sNotFoundExcept ion:com.mysql.j dbc.Dr iver"

            can any one tell how to solve my problem
            .




            Originally posted by sicarie
            My guess would be that the problem lies in your 1) classpath, or 2) declaration.

            Did you include the JDBC driver in your classpath, or attach it to your project? If so, can wee see your declaration (the classforname, etc...)?

            Comment

            • sicarie
              Recognized Expert Specialist
              • Nov 2006
              • 4677

              #7
              Originally posted by menmysql
              thanks for your reply,

              i downloaded mysql connector/j from mysql.com ,i copied the .jar file in to ./tomcat 5.0/common/lib and i set path at environment variables. i tryed at two different systems. in one system which is upgraded from mysql 4.0.17 to 5.0 and webserver is tomcat 5x, at this system i am getting java.sql.SQLExc eption: Communication link failure: Bad handshake


              then i went to my friends place and i freshely installed java 6.0, tomcat 6x, mysql 5.0 and mysql connector/j 5.0 and i set path as above i mentiond. but this time i am getting different exception that is "java.lang.Clas sNotFoundExcept ion:com.mysql.j dbc.Dr iver"

              can any one tell how to solve my problem
              .
              Ok, can we see the code where you do the declaration?

              Comment

              • menmysql
                New Member
                • Mar 2007
                • 53

                #8
                thanks for your reply

                i am keeping my program as follows
                Code:
                <%@ page import="java.sql.*"%>
                <%! String Name;%>
                <%
                	try
                	{
                		Class.forName("com.mysql.jdbc.Driver");
                		Connection con=DriverManager.getConnection("jdbc:mysql://localhost/cheer","root","");
                		Statement st=con.createStatement();
                		String Q="select name from how";
                		ResultSet rs=st.executeQuery(Q);
                		while(rs.next())
                		{
                			Name=rs.getString(1);
                			out.println(Name);
                		}
                		rs.close();
                		st.close();
                		con.close();
                	}
                	catch(Exception e)
                	{
                		out.println(e);
                	}
                	
                	%>
                can you tell me where i did mistake

                regards



                Originally posted by sicarie
                Ok, can we see the code where you do the declaration?

                Comment

                • itsraghz
                  New Member
                  • Mar 2007
                  • 124

                  #9
                  in case of 'Communication Link Failure' means the database might not have started propertly.

                  With MySQL 5.0 version, you might have installed it as an Windows Executable Service. In that case, you need to ensure whether the MySQL Service is started or not.

                  Go to Run
                  type "services.m sc"
                  There check "MySQL" service is running or not. Also check whether its Manual or Automatic. Manual means you need to start it everytime.

                  Hope this helps....

                  Comment

                  • sicarie
                    Recognized Expert Specialist
                    • Nov 2006
                    • 4677

                    #10
                    Yeah, good call itsragz - the code looks right... but I'll check it when I get back to my compiler.

                    Comment

                    • menmysql
                      New Member
                      • Mar 2007
                      • 53

                      #11
                      thanks for your reply,

                      i checked, it is set to automatic only






                      Originally posted by itsraghz
                      in case of 'Communication Link Failure' means the database might not have started propertly.

                      With MySQL 5.0 version, you might have installed it as an Windows Executable Service. In that case, you need to ensure whether the MySQL Service is started or not.

                      Go to Run
                      type "services.m sc"
                      There check "MySQL" service is running or not. Also check whether its Manual or Automatic. Manual means you need to start it everytime.

                      Hope this helps....

                      Comment

                      • sicarie
                        Recognized Expert Specialist
                        • Nov 2006
                        • 4677

                        #12
                        Originally posted by menmysql
                        thanks for your reply,

                        i checked, it is set to automatic only
                        And it is started?

                        What version of mysql.jdbc driver are you using?

                        Comment

                        • menmysql
                          New Member
                          • Mar 2007
                          • 53

                          #13
                          i am using mysql connector/j 5.0


                          Originally posted by sicarie
                          And it is started?

                          What version of mysql.jdbc driver are you using?

                          Comment

                          • menmysql
                            New Member
                            • Mar 2007
                            • 53

                            #14
                            thanks to all

                            at last i got sucess. my jsp program retriving record from my data base. thanks a lot to all who gave sugessions all these days.


                            thanks thanks a lot


                            regards

                            Narasimha Raju Naidu

                            Comment

                            • itsraghz
                              New Member
                              • Mar 2007
                              • 124

                              #15
                              Originally posted by menmysql
                              thanks to all

                              at last i got sucess. my jsp program retriving record from my data base. thanks a lot to all who gave sugessions all these days.


                              thanks thanks a lot


                              regards

                              Narasimha Raju Naidu
                              thats gr8.. keep going..

                              Comment

                              Working...