0

I have a JSP that looks like this

<%
Class.forName("com.mysql.jdbc.Driver"); 
java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root"); 

Statement st= con.createStatement(); 

ResultSet rs=st.executeQuery("select * from example");
.
.
.
%>

When i request the jsp I get this error:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.test_jsp._jspService(test_jsp.java:95)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:126)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:186)
org.apache.jsp.test_jsp._jspService(test_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.26 logs.

2 Answers 2

3

simply put the mysql-connector-java-5.1.13-bin.jar file in the WEB-INF/lib of your directory present inside webapps of tomcat.

Sign up to request clarification or add additional context in comments.

Comments

2

add mysql mysql-connector-java-5.1.13-bin jar to your class path.

5 Comments

i have added them but in vain
<% Class.forName("com.mysql.jdbc.Driver"); java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","mypc"); Statement st= con.createStatement(); ResultSet rs=st.executeQuery("select * from example"); . . .%>
it is showing org.apache.jasper.JasperException: An exception occurred processing JSP page /test1.jsp at line 13 and line no. 13 is 13: Class.forName("com.mysql.jdbc.Driver"); plz help its urgent.
did u try to recompile and re-deploy everything after making the classpath addition ? cause your problem really looks so simple as just a class not found
Are there any guides or instructions published on how to "download add mysql connector to jasper studio"? It seems amazing that they would ship with no DB connectors, and then give zero instructions on how to add them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.