Eclipse - dodaj .jar do Dynamic Web Project
Kiedy używam następującego kodu w zaćmieniuDynamic Web Project
wewnątrzservlet
, lubię to :
@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");//here the exception
}
}
rzuca wyjątek:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
w linii:
Class.forName("com.mysql.jdbc.Driver");
Na ścieżce Build dynamicznego projektu WWW dodałem jar:
mysql-connector-java-5.1.21-bin.jar
Dodaję migawkę folderu, możesz zobaczyć, gdzie jest wymagany słój -