When I copy mysql jdbc driver to JDK's\jre\lib\ext, it execute perfectly well. Now, I want to use the jdbc by specifying its classpath to environment variable.
But, after doing so, my program throws exception :
"java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost/books"
How do I set the classpath?
解决方案
You should not be putting ANY JARs in the jre/lib/ext folder.
You set the CLASSPATH using the -classpath option on javac.exe when you compile and java.exe when you run. Make sure that your code and all 3rd party JARs are in the CLASSPATH when you compile and run. Windows uses the semi-colon as the separator; Linux uses colon.
Maybe you need to start here: