说你的那个类不存在,你仔细检查看你引用的名字是否正确,注意大小写,ResultSetTableModel

解决方案 »

  1.   

    import java.awt.*;
    import java.awt.event.*;
    import  java.sql.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;public class DisplayQueryResults extends JFrame{
      static final String JDBC_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
      static final String DATABASE_URL =
          "jdbc:odbc:driver={Microsoft Access Driver(*.mdb)};DBQ=c:\\济钢二区.mdb";
     static final String DEFAULT_QUERY="SELECT * FROM  ic卡号";
     private ResultSetTableModel tableModel;
     private JTextArea queryArea;
     public DisplayQueryResults( ){
       super("Displaying Query Results");
     try{
       System.setProperty("acess.system.home", "c:/");
       tableModel = new ResutsSetTableModel (JDBC_DRIVER, DATABASE_URL,
                                            DEFAULT_QUERY);
       queryArea = new JTextArea(DEFAULT_QUERY, 3, 100);
       queryArea.setWrapStyleWord(true);
       queryArea.setLineWrap(true);
       JScrollPane scrollPane = new JScrollPane(queryArea,
                                                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
       JButton submitButton =new JButton("Submit Query");
       Box box=Box.createHorizontalBox();
       box.add(scrollPane);
       box.add(submitButton);
       JTable resultTable=new JTable(tableModel);
       Container c=getContentPane();
       c.add(box,BorderLayout.NORTH);
       c.add(new JScrollPane(resultTable),BorderLayout.CENTER);
       submitButton.addActionListener(
           new ActionListener(){
         public void actionPerformed(ActionEvent event)
         {
           try{
             tableModel.setQuery(queryArea.getText());
           }
           catch(SQLException sqlException){
             JOptionPane.showMessageDialog(null,sqlException.getMessage(),"Database error",
                                           JOptionPane.ERROR_MESSAGE);
            try{
              tableModel.setQuery(DEFAULT_QUERY);
              queryArea.setText(DEFAULT_QUERY);
            }
            catch(SQLException sqlException2){
              JOptionPane.showMessageDialog(null,sqlException2.getMessage(),"Database error",
                                        JOptionPane.ERROR_MESSAGE);
              tableModel.disconnectFromDatabase();
              System.exit(1);
                }
              }
            }
           }
       );
        setSize(500,200);
        setVisible(true);
     }
     catch(ClassNotFoundException classNotFound){
       JOptionPane.showMessageDialog(null,"Cloudscape driver not found","Driver not found",
                                     JOptionPane.ERROR_MESSAGE);
       System.exit(1);
     }
     catch(SQLException sqlException){
       JOptionPane.showMessageDialog(null,sqlException.getMessage(),
                                     "Database error",JOptionPane.ERROR_MESSAGE);
       tableModel.disconnectFromDatabase();
       System.exit(1);
     }
     setDefaultCloseOperation(DISPOSE_ON_CLOSE);
     addWindowListener(
          new WindowAdapter()
     {
       public void windowClosed(WindowEvent event)
       {
         tableModel.disconnctFromDatabase();
         System.exit(0);
       }
     }
     );
     }
     public static void main(String args[])
    { new DisplayQueryResults();
     }
    }
    这是源代码,我检查过,没有错啊