SHARE
TWEET

Untitled

a guest Dec 29th, 2016 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Error: 500
  2.  
  3. Internal Servlet Error:
  4. java.lang.NoClassDefFoundError: com/mysql/jdbc/Driver
  5.     at QueryConst.connect(QueryConst.java:23)
  6.     at QueryConst.doPost(QueryConst.java:38)
  7.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:747)
  8.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
  9.     at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155)
  10.     at com.sun.web.core.InvokerServlet.service(InvokerServlet.java:168)
  11.     at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
  12.     at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155)
  13.     at com.sun.web.core.Context.handleRequest(Context.java:414)
  14.     at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:139)
  15. Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
  16.     at java.net.URLClassLoader.findClass(Unknown Source)
  17.     at java.lang.ClassLoader.loadClass(Unknown Source)
  18.     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  19.     at java.lang.ClassLoader.loadClass(Unknown Source)
  20.     ... 10 more
  21.    
  22. import java.sql.*;
  23. import javax.servlet.*;
  24. import javax.servlet.http.*;
  25. import java.io.*;
  26.  
  27. public class QueryConst extends HttpServlet {
  28.  
  29.     static Connection link;
  30.     static String myURL = "jdbc:mysql:";
  31.     static final private String CONTENT_TYPE = "text/html";
  32.     /*  *************************** */
  33.     /*  CONNECTING TO THE DATA BASE */
  34.     /*  *************************** */
  35.  
  36.     public static void connect() {
  37.         try {
  38.             DriverManager.registerDriver(new com.mysql.jdbc.Driver());
  39.             link = DriverManager.getConnection(myURL+"//localhost/airliner?user=root+&password=");
  40.         } catch (SQLException e) {
  41.             System.out.println("Connection failure: " + e.getMessage());
  42.         }
  43.     }
  44.  
  45.     /*  ******************************* */
  46.     /*  CATCHING THE HTTP POST REQUEST  */
  47.     /*  ******************************* */
  48.  
  49.     public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  50.         Statement question;
  51.         String query;
  52.         ResultSet answer;
  53.         connect();
  54.         response.setContentType(CONTENT_TYPE);
  55.         PrintWriter out = response.getWriter();
  56.         out.println("<html>");
  57.         out.println("<head><title>SQL request</title></head>");
  58.         out.println("<body>");
  59.         out.println("<form method="post" action="http://localhost:8080/servlet/queryConst">");
  60.         out.println("SELECT");
  61.         out.println("<select name="champs" id="champsTable"></select>");
  62.         out.println("FROM");
  63.         out.println("<select name="table" id="choixTable"></select>");
  64.         out.println("WHERE");
  65.         out.println("<select name="condition1" id="condition1"></select>");
  66.         out.println("<select name="operateur" id="operateur">"
  67.                 + "<option value="<"><</option>"
  68.                 + "<option value=">">></option>"
  69.                 + "<option value="=">=</option>"
  70.                 + "<option value="<="><=</option>"
  71.                 + "<option value=">=">>=</option>"
  72.                 + "</select>");
  73.         out.println("<select name="condition2" id="condition2"></select>");
  74.         out.println("<input type="submit" value="Go"></p>");
  75.         out.println("</form>");
  76.  
  77.         out.println("</body></html>");
  78.  
  79.     }
  80.  
  81.     /*  ******************************* */
  82.     /*  CATCHING THE HTTP GET REQUEST   */
  83.     /*  ******************************* */
  84.  
  85.     public void doGet(HttpServletRequest requete, HttpServletResponse reponse) throws ServletException, IOException {
  86.         doPost(requete,reponse);
  87.     }
  88.  
  89.     /*  ******************* */
  90.     /*  SERVLET DESTRUCTOR  */
  91.     /*  ******************* */
  92.  
  93.     public void destroy() {
  94.         super.destroy();
  95.         try { link.close();
  96.         } catch (Exception e) {
  97.             System.err.println(e.getMessage());
  98.         }
  99.     }
  100. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top