java,未找到类com.mysql.jdbc.Driver异常 [英] java, class not found exception com.mysql.jdbc.Driver
问题描述
我正在尝试在Java程序中创建运行以下命令,但出现此错误.
I am trying to create the run the following in java program, but i am getting this error.
java.lang.ClassNotFoundException:com.mysql.jdbc.Driver位于 org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) 在 org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) 在java.lang.Class.forName0(本机方法)在 java.lang.Class.forName(未知来源)
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source)
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
在构建路径中,我添加了mysql连接器jar文件
in build path, i have added the mysql connector jar file
推荐答案
在Eclipse中,右键单击项目,然后选择Build Path-> Configure Build Path.选择库"选项卡,然后选择添加罐子"按钮.然后选择MySQL jar文件,如项目所示.然后按OK,然后按OK.现在应该可以了.
In Eclipse, right-click on the project and select Build Path -> Configure Build Path. Select the Libraries tab, then the Add Jars button. Then select the MySQL jar file as shown in your project. Then press OK then OK. It should now work.
这篇关于java,未找到类com.mysql.jdbc.Driver异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!