java.lang.ClassNotFoundException:Eclipse 上的 com.mysql.jdbc.Driver

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25074949/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:49:34  来源:igfitidea点击:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver on eclipse

eclipsejspjdbctomcat7mysql-connector

提问by Ben

I have installed Eclipse Luna recently to do programming on JSP. Currently i'm trying to connect it with JDBC. I have downloaded mysql J connector and added mysql-connector-java-5.1.31-bin.jarto the build path. I've trying running in on my browser and i get the following error:

我最近安装了 Eclipse Luna 来在 JSP 上进行编程。目前我正在尝试将它与 JDBC 连接。我已经下载了 mysql J 连接器并添加mysql-connector-java-5.1.31-bin.jar到构建路径中。我试图在我的浏览器上运行,但出现以下错误:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

I'm pretty sure that my settings are correct in terms of setting the path. I also have set up the CLASSPATH in environment variables just in case that is the main problem, but still i'm facing the same problem.

我很确定我的设置在设置路径方面是正确的。我还在环境变量中设置了 CLASSPATH,以防万一这是主要问题,但我仍然面临同样的问题。

Can anyone help me?

谁能帮我?

回答by Madhavi Talla

U need to add jar file to build path

你需要添加jar文件来构建路径

right click on project->build path->configure build path->libraries tab ->add external jar

右键单击项目->构建路径->配置构建路径->库选项卡->添加外部jar

browse it and add it.

浏览它并添加它。

after adding also if u not getting same error, then

添加后如果你没有得到同样的错误,那么

You must include the jar file in the Deployment Assembly of the Project.......

您必须在项目的部署程序集中包含 jar 文件......

1)select the web project which contains the jsp file...

 2)select Project tab in the menubar in Eclipse

3)select properties in the drop down menu

4)select Deployment Assembly

5)Add your ojdbc6.jar file in it..

5) 在其中添加您的 ojdbc6.jar 文件..

Hope this will help u..

希望这会帮助你..

回答by A4L

Yes your settings are right for building the application, running it needs other settings. You need to place the jar file either in CATALINA_HOME/libor in <your-app>/WEB-INF/libso that the driver is found at run time. The latter is preferable.

是的,您的设置适合​​构建应用程序,运行它需要其他设置。您需要将 jar 文件放入CATALINA_HOME/lib或放入其中,<your-app>/WEB-INF/lib以便在运行时找到驱动程序。后者是优选的。