java - 无法连接到 mysql 数据库。驱动程序管理器错误。Java + netBeans
问题描述
不知道我做错了什么,为什么 DriverManager 用红色下划线和 NetBeans 建议创建一个 DriverManager 类...
public class regularcustomerreg extends javax.swing.JFrame {
/**
* Creates new form regularcustomerreg
*/
public regularcustomerreg() {
initComponents();
}
Connection con;
PreparedStatement pst;
public void Connect() {
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/lutonhotel", "root", "");
} catch (ClassNotFoundException ex) {
Logger.getLogger(regularcustomerreg.class.getName()).log(Level.SEVERE, null, ex);
}
}
解决方案
推荐阅读
- spring - Spring JPA + Oracle 12 C 模式验证问题
- autodesk-forge - Autodesk Forge 数据连接器请求的 csv 文件不完整
- ansible - 通过 Ansible 模块关闭 Ovirt 上的多个虚拟机
- python - sqlite3.OperationalError:没有这样的表:用户
- .net - 可访问性不一致:参数类型“IInventoryServices”的可访问性不如方法
- c++ - 长字符串在Release模式下调用字符串的析构函数
- flutter - BLoC mapEventToState() 未触发
- asp.net-core - 在另一个端口上公开 ASP.NET Core Prometheus 指标
- c# - 如何在 ASP.NET Core 登录重定向中强制 returnUrl 的绝对 uri 类型?
- javascript - 带有 React 的样式化组件 - 表单 onSubmit 不起作用