Results 1 to 11 of 11
Like Tree2Likes
  • 1 Post By sevoxx
  • 1 Post By Tolls

Thread: working with servlet on netbeans through wamp server ,problem in loading Driver

  1. #1
    viki1719 is offline Member
    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Default working with servlet on netbeans through wamp server ,problem in loading Driver

    Hi Everyone,

    I am trying to write simple servlet having jdbc code that connect to mysql database and retrieve a details of table fields , and i am using netbeans and wamp server to do my job.
    let me explain what problem i am facing.....
    Apache tomcat is complaining regarding Driver that....
    java.lang.ClassNotFoundException: com.jdbc.mysql.Driver

    and what i have tried to solve this..
    1-i attached mysql-connector-java-5.1.6.jar to my project library
    but i found the same problem ,when i observed wamp server's containing mysql folder that is- wamp/bin/mysql 5.1.36
    and also i have been tried by adding mysql-connector-java-5.1.25 but still facing same above issue.

    i am not getting any clue that what i am missing or any extra stuff to do with my code.
    please help me out. your help would be highly appreciated.

  2. #2
    sevoxx is offline Oracle Java Developer
    Join Date
    Apr 2013
    Location
    In a PineApple Under the Sea
    Posts
    20
    Rep Power
    0

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    This is a classic case of RTFM.
    viki1719 likes this.

  3. #3
    viki1719 is offline Member
    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    Quote Originally Posted by viki1719 View Post


    This is a classic case of RTFM.

    I am stuck in this issue ,please help me out to resolve this problem ,any hint or any link would be appreciated.
    looking forward for your response.

    thanks in advance for your time to read this thread.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    Where have you put your Driver jar?
    Has it ended up in the WEB-INF/lib directory?
    viki1719 likes this.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    viki1719 is offline Member
    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    Thanks Tolls , for your reply
    I am using netbeans IDE and i attached mysql jar file to libraries folder into my project . but still getting java.lang.ClassNotFoundException.
    and also unable to track out that which thing i am missing...

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    When you deploy it.
    You say you are deploying to Tomcat, so check that the WEB-INF/lib folder of your deployment contains the jar file.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    viki1719 is offline Member
    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    Quote Originally Posted by Tolls View Post
    When you deploy it.
    You say you are deploying to Tomcat, so check that the WEB-INF/lib folder of your deployment contains the jar file.

    as you suggested ,i am trying to look WEB-INF/lib folder present in my project in netbeans but there is no such exact match available .
    do you mean that i should create a new folder named lib inside WEB-INF in netbeans ?
    there is a libraries folder available parallel to web pages inside web context and i added already jar files in it. please help, i am novice not getting exact idea that what i am missing?....
    thanks

  8. #8
    viki1719 is offline Member
    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    Quote Originally Posted by Tolls View Post
    When you deploy it.
    You say you are deploying to Tomcat, so check that the WEB-INF/lib folder of your deployment contains the jar file.
    yes! when i checked for mysql-connector-java-5.1.6.jar availability in the WEB-INF/lib location then i found it inside build\web\WEB-INF\lib location which is automatically placed by netbeans after build.
    but still i am getting the same error. i would like to show you the sample code which i am using....

    Java Code:
    package com.wamp.servlet;
    
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class ServletWithWamp extends HttpServlet {
       @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            
            try{
                Class.forName("com.jdbc.mysql.Driver");
                Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/goldsgym","root","");
                PreparedStatement stmt=con.prepareStatement("select * from employee");
                 ResultSet result=stmt.executeQuery();
            while(result.next()){
                System.out.println(result.getString(1)+" "+result.getString(2)+" "+result.getString(3)+" "+result.getString(4)+" "+result.getString(5));
                
               
            }
            
            
            }
            catch(Exception e){
                e.printStackTrace();
            }
            
        }

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    I think you've got the class name wrong.
    com.mysql.jdbc.Driver
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    viki1719 is offline Member
    Join Date
    May 2013
    Posts
    8
    Rep Power
    0

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    Quote Originally Posted by Tolls View Post
    I think you've got the class name wrong.
    com.mysql.jdbc.Driver
    Oh! thank you very much Tolls for your hint ,container were complaining again and again on that line but i was not focusing on the fully qualified driver name where i wrote wrong. now i corrected .
    than you so much once again because you are the only folks who interested to come forward for help to new comers .

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: working with servlet on netbeans through wamp server ,problem in loading Driver

    You don't actually need that Class.forName() line anymore.
    Connector-J is a sufficiently modern driver.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Problem with loading driver
    By b01g in forum New To Java
    Replies: 7
    Last Post: 07-15-2011, 06:41 PM
  2. WAMP Server TOMCAT PROBLEM?
    By chathura87 in forum Java Servlet
    Replies: 0
    Last Post: 03-03-2011, 03:03 PM
  3. Problem loading JDBC SQL driver.
    By tarkowc in forum New To Java
    Replies: 16
    Last Post: 01-25-2011, 05:23 PM
  4. Error loading driver
    By Gary20 in forum JDBC
    Replies: 21
    Last Post: 01-25-2011, 03:54 PM
  5. Problem with .jar working with netbeans
    By chipimdp in forum NetBeans
    Replies: 1
    Last Post: 05-14-2010, 09:25 AM

Posting Permissions

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