Maison >base de données >tutoriel mysql >mysql的驱动程序的加载
mysql
public class ConnectionDemo01 {
public static final String DBDRIVER ="org.git.mm.mysql.Driver";
public static void main(String[] args) {
try {
Class.forName(DBDRIVER);
} catch (Exception e) {
e.printStackTrace();
}
}
}
运行这段代码是会出现错误:
java.lang.ClassNotFoundException: org.git.mm.mysql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at mysql.cn.ConnectionDemo01.main(ConnectionDemo01.java:7)
但是我的CLASSPATH是正确的,我重新设置了好几次了,不会有错的。