This is my first time working with JSP. I've set up a tomcat 9.0.8 server and I'm using Java 8.5, along with MySQL 8.0.11, and I'm using Eclipse EE on Windows 10.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I've encountered this error, and I've seen multiple other people ask the same question so I've tried a lot of solutions but none of them work. I've downloaded mysql-connector-java-8.0.11 These are some of the solutions that I've tried so far:
- Added
<%@ page import = "com.mysql.jbdc.Driver %>
at start of file - Tried both
Class.forName("com.mysql.jdbc.Driver");
andClass.forName("com.mysql.jdbc.Driver").newInstance();
Added the JAR file in:
- apache-tomcat-9.0.8\lib
- ..\eclipse-workspace\ProjectFolder
- ..\eclipse-workspace\ProjectFolder\WEB_INF\lib\
Added in the BUILD PATH for the project as an external JAR
Please help out. I don't know what more to do.
EDIT: This is my current code.
<%@
page import="java.sql.*, javax.sql.*"
%>
<%
String name = request.getParameter("name");
String age = request.getParameter("age");
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "user", "pass");
Statement s = con.createStatement();
%>
<html>
<head>
<title> Processing </title>
</head>
<body>
Hello <%=name%>
</body>
</html>
EDIT:
I've got it working by selecting the JAR in the "order and export" settings from the build path options.