Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.ClassNotFoundException: com.mysql.cj.jdbc.driver
时间: 2023-12-19 15:32:12 浏览: 362
eclipse 报错java.lang.ClassNotFoundException: com.mysql.jdbc.Driver错误解决
5星 · 资源好评率100%
以下是处理异常的示例代码:
```java
public class BUtil {
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://localhost:3306/library_db?useUnicode=true&characterEncoding=UTF-8";
private static final String USER = "root";
private static final String PWD = "666918";
static {
try {
Class.forName(DRIVER);
} catch (ClassNotFoundException e) {
throw new RuntimeException("java.lang.ClassNotFoundException: " + e.getMessage());
}
}
}
```
阅读全文