0

I am using JAVA, Netbeans IDE and SQL Server 2008. so, I want to display one record on my form. I have got a message that is "Driver Error" before the form appears. How can I solve this? **

Here is my code

package javaapplication;

import java.sql.*;    
import javax.swing.JOptionPane;    
public class EmployeeInfo extends javax.swing.JFrame {   
Connection cn;    
Statement stm;    
ResultSet rs;    
String url = "jdbc:odbc:EMPDB";
    public EmployeeInfo() {
        initComponents();
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    cn = DriverManager.getConnection(url);
                    stm = cn.createStatement();
                    rs = stm.executeQuery("select * from  employee");
                    while (rs.next())
                    {
                        txtID.setText(rs.getString(1));
                        txtName.setText(rs.getString(2));
                        txtPhone.setText(rs.getString(3));           
    }
        }
         catch(SQLException e)
         {
             JOptionPane.showMessageDialog(this, "SQL Error");      
         }
        catch(ClassNotFoundException cnfe)
        {
            JOptionPane.showMessageDialog(this, "Driver Error");
        }
    }

 public static void main(String args[]) {  /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new EmployeeInfo().setVisible(true);
            }
        });
    }

I am using this form and it has this problem. How could I recover it?

0 Answers0