add jar to dynamic web project in eclipse
===

I have regular java project with only Main class  :

    import java.sql.*;
    
    public class Main
    {
        public static void main (String[] args) throws ClassNotFoundException, SQLException
        {
        	Class.forName("com.mysql.jdbc.Driver");
        	
        	String string = "jdbc:mysql://localhost:3306/testdb";
        	Connection con = DriverManager.getConnection(string , "root" , "");
        	PreparedStatement statement = con.prepareStatement("select * from names"); 
        	ResultSet result = statement.executeQuery();
        	while (result.next())
        	{
        		System.out.println(result.getString(1) + " " + result.getString(2));
        	}
        	
        	
        }
    }

that's run OK and prints all the names in `names` table  . 


But when I use same code in eclipse dynamic web project inside servlet , like this :


    package control;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    
    import Model.Customer;
    @WebServlet("/CreateCustomerServlet")
    public class CreateCustomerServlet extends HttpServlet {
    	private static final long serialVersionUID = 1L;
    	
    	private void test() throws SQLException, ClassNotFoundException {
    		// use the JAR ...
    		Class.forName("com.mysql.jdbc.Driver");
    
    		String string = "jdbc:mysql://localhost:3306/testdb";
    		Connection con = DriverManager.getConnection(string, "root", "");
    		PreparedStatement statement = con
    				.prepareStatement("select * from names");
    		ResultSet result = statement.executeQuery();
    		while (result.next()) {
    			System.out.println(result.getString(1) + " " + result.getString(2));
    		}
    
    	}
    	
    }
	

it throw exception in the line `Class.forName("com.mysql.jdbc.Driver");`

In the Build path of the dynamic web project I added the jar `mysql-connector-java-5.1.21-bin.jar` .

I add snapshot of the folder , you can see where is the required jar -

![enter image description here][1]


  [1]: http://i.stack.imgur.com/bR1Ub.png