通过netbeans使用mysql时发生意外错误

w6lpcovy  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(148)

这是我的源代码是无错误的。我搞不清楚出了什么问题。它给出了一个意外的错误,说“java.sql.driver”,我不知道该怎么解释。

String v=jTextField1.getText();
    DefaultTable DefaultTableModel = null;
    DefaultTable model;
    model = (DefaultTableModel);
    jTable1.getModel();
    try
            {
            Class.forName("java.sql.driver"); 
            Connection c;
            c=DriverManager.getConnection("jdbc:mysql://local host/hospital","root","hope");
            Statement s=c.createStatement();

            String q;
        q = ("Select * from hospital where Patient_Name=v");

            ResultSet r=s.executeQuery(q);
            while(r.next())
            {
                int PNO=r.getInt("PNO");
                String Patient_Name=r.getString("Patient_Name");
                int Age=r.getInt("Age");
                String Gender=r.getString("Gender");
                String Department=r.getString("Department");
                String Doctor=r.getString("Doctor");
                model.addRow(new Object[]
                {PNO,Patient_Name,Age,Gender,Department,Doctor});

                r.close();
                s.close();
                e.close();
            }
            }catch (ClassNotFoundException e)
            {
                JOptionPane.showMessageDialog(null,e.getMessage());
            } catch (SQLException e) {
                JOptionPane.showMessageDialog(null,e.getMessage());
    }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题