Java eclipse无法加载jdbc驱动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20431044/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to load jdbc driver eclipse
提问by Aman Deep Gautam
I get the following error while trying to load MySQL Driver:
尝试加载 MySQL 驱动程序时出现以下错误:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at amazon.category.database.MerchantAdoptionStats.main(MerchantAdoptionStats.java:96)
Th relevant code is:
相关代码是:
try {
Class.forName("com.mysql.jdbc.Driver"); //line 96
//Some more code
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
I am using eclipse and here are the settings(please see the added jar in classpath
):
我正在使用 Eclipse,这里是设置(请参阅 中添加的 jar classpath
):
What else am I missing?
我还缺少什么?
EDIT: Run time configrations:
编辑:运行时配置:
采纳答案by Amit Sharma
You have included mysql jdbc drivers in build path of your project, which is not same as runtime path.
您在项目的构建路径中包含了 mysql jdbc 驱动程序,这与运行时路径不同。
Check your runtime classpath by going to Run -> Run Configurations
and select your application configuration. Check the classpath setting there.
通过转到Run -> Run Configurations
并选择您的应用程序配置来检查您的运行时类路径。检查那里的类路径设置。