Mysql driver drum not recognized
I have a token class file in a jar file. Token class files are the class that jdbc uses to fetch data from the database. However, when I call the jar file, it doesn't seem to recognize the external jar file of the external mysql file.
The error is pointed to this line Class.forName (driver) ;.
I refer to the mysql driver in the ant build file and in every classpath I could think of.
<mkdir dir="build/server/dist"/>
<jar destfile="build/server/dist/VNCOverHTTPServer.jar" basedir="build/server/classes">
<manifest>
<attribute name="Main-Class" value="jhttpserver.JHttpServer"/>
<attribute name="Class-path" value="lib/servlet.jar lib/mysql-connector-java-5.1.7-bin.jar config/"/>
</manifest>
</jar>
Nothing works? any help would be appreciated.
thank
java.lang.ClassNotFoundException: mysql at java.net.URLClassLoader $ 1.run (URLClassLoader.java:200) at java.security.AccessController.doPrivileged (native method) at java.net.URLClassLoader.findClass (URLClassLoader ).java:200 at java.lang.ClassLoader.loadClass (ClassLoader.java:316) at sun.misc.Launcher $ AppClassLoader.loadClass (Launcher.java:288) at java.lang.ClassLoader.loadClass (ClassLoader.java:251) at java. lang.ClassLoader.loadClassInternal (ClassLoader.java:374) at java.lang.Class.forName0 (native method) at java.lang.Class.forName (.java class: 169) at socksviahttp.server.token.getConnection (token. java: 58) to socksviahttp.server.token.exists (token.java:75) to socksviahttp.server.ServletSocks.doPost (ServletSocks.java:328) to javax.servlet.http.HttpServlet.service (HttpServlet.ava ) to javax.servlet.http.HttpServlet.service (HttpServlet.java:853) to jhttpserver.JHttpServerThread.run (JHttpServerThread.java:217)
And the line registering the mysql driver is something like the lines:
Class.forname("com.mysql.jdbc.Driver");
The class loader error appears to be for the frivolous class "mysql" and not for the package that the package references. You usually only see this error when dynamically loading a class without specifying the fully qualified class name.
What are you using to load the mysql driver class? if it's a spring config file then you probably don't have the fully qualified class name in the config file.
And I just noticed the lower case "Class-path". It should be "Class-Path"
source to share
When you run the jar file, either by double clicking it or from the command line):
java -jar VNCOverHTTPServer.jar
then in the directory where your jar is located, there should be a lib folder with the necessary jars. Is this the case?
Update: It can be seen from the bug report that you are using URLClassLoader to load the mysql class. Adding the jar file to the classpath will not help, you need to make the class available via the url link.
source to share