mercredi 5 août 2015

Unable to connect to database using jsp in ubuntu


I am trying to connect with the mysql database in linux. I know I am making mistake in including the jar file. I don't know how to give reference to those jar files in linux the way we reference them in eclipse or Netbeans. I am running those jsp pages using tomat7.

type Exception report

message An exception occurred processing JSP page /first.jsp at line 9

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

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /first.jsp at line 9

6: <% 7:
8: out.println("Hello World!"); 9: Class.forName("com.mysql.jdbc.Driver"); 10: Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/MeshliumDB","myuser","mypass"); 11: if(con!=null) 12: out.println("Connection Established");

Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568) 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:727)

root cause

javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845) org.apache.jsp.first_jsp._jspService(first_jsp.java:86) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 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:727)

root cause

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1718) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569) 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:191) org.apache.jsp.first_jsp._jspService(first_jsp.java:73) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 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:727)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire