在应用程序中,我有JDBC驱动程序(异常java.lang.ClassNotFoundException:com.mysql.cj.jdbc.Driver) [英] In application I have acsess to JDBC driver (exception java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver)

查看:5086
本文介绍了在应用程序中,我有JDBC驱动程序(异常java.lang.ClassNotFoundException:com.mysql.cj.jdbc.Driver)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相同的项目 servlet 应用程序不起作用,但是hello world方法,在相同的项目中,是的。
这里是项目的图片。

The same project servlet application does not work, but "hello world" method, in the same project, yes. Here the picture ofproject.

版本:

Intellij IDEA - 2018.2

mySQL 驱动程序版本: 8.0.11 ,驱动程序 com.mysql.cj。 jdbc.Driver

mySQL driver version: 8.0.11, driver com.mysql.cj.jdbc.Driver

servlet 9.0.81

代码:

Class.forName(dbDriver).newInstance();
dbConnection = DriverManager.getConnection(connectionUrl, userName, password);

例外:

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

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

顺便说一句:

我在 PON.xml中没有 mysql 依赖关系时收到同样的异常

The same exception I receive also without mysql dependency in PON.xml

所以,这是问题,或者我遗漏了什么。
谢谢

So, this is issue or I missing something. Thanks

更新

已解决:我们需要在工件中添加库

推荐答案

请确保所有必需的罐子也包含在工件配置

Please make sure all the required jars are also included in the Artifact configuration that you are deploying on the application server.

这篇关于在应用程序中,我有JDBC驱动程序(异常java.lang.ClassNotFoundException:com.mysql.cj.jdbc.Driver)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆