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

Ben*_*Ben 2 eclipse jsp jdbc mysql-connector tomcat7

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

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Run Code Online (Sandbox Code Playgroud)

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

谁能帮我?

Mad*_*lla 6

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

右键单击project-> build path-> configure build path-> libraries选项卡 - >添加外部jar

浏览并添加它.

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

您必须在项目的部署程序集中包含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
Run Code Online (Sandbox Code Playgroud)

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

希望这会对你有所帮助..