首页 > 解决方案 > 无法连接到 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);
        }
        
    }

标签: javamysqljdbc

解决方案


推荐阅读