title: ClassNotFoundException in Class.forName("com.mysql.jdbc.Driver").newInstance() related to java applet
body: <p>I created an <code>Applet</code> which connect to mysql database and insert rows in db. It is running file on localhost. But when I published the same on php web server, the mysql connect jar is not found. I am running the <code>Applet</code> from that server in the form of HTML file and I am getting exception of <code>ClassNotFoundException</code>. I have already put <code>mysql-connector-java-5.1.12-bin.jar</code> in the same place where html and other class files exist. Also I created <code>web-inf/lib</code> on root and put the jar there but no luck. Below is the code.</p>
  
  <pre><code>Connection conn=null;
  try {
      String url = "jdbc:mysql://&lt;ipaddress of domain&gt;:3306/db_name";
      String driver = "com.mysql.jdbc.Driver";
      String userName = "username"; 
      String password = "password";
      try {
          Class.forName(driver).newInstance();
          conn = DriverManager.getConnection(url,userName,password);
          Statement statement = conn.createStatement();
          statement.executeUpdate("insert query");
          conn.close();
      } catch (SQLException e) {
          showAlert("Error=" + e.getMessage() + ",ErrorCode="+e.getErrorCode() + "," + e.getSQLState());
      }
  } catch (InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      showAlert("InstantiationException=" + e.getMessage());
  } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      showAlert("IllegalAccessException=" + e.getMessage());
  } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      showAlert("ClassNotFoundException=" + e.getMessage());
  }
  </code></pre>
  
  <p>Below is the HTML file code</p>
  
  <pre><code>&lt;HTML&gt;
  &lt;BODY&gt;
  &lt;APPLET CODE=app_test.class WIDTH=200 HEIGHT=100 archive='mysql-connector-java-5.1.12-bin.jar'&gt;
  &lt;/APPLET&gt;
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>