Sqlite列判断错误

Sqlite Column Determination Error

我正在尝试从 J 组合框中选择并使用它从数据库中查找 table。但是却出现了一个错误:

我的代码:

JButton btnGo = new JButton("Go!");
    btnGo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Connection conni = null;
            ResultSet rs=null;
            PreparedStatement pst=null;
            try{
                Class.forName("org.sqlite.JDBC");
                conni  = DriverManager.getConnection("jdbc:sqlite://C://Users//Asus//Dropbox//TireShop.sqlite");
                String x = comboBox.getSelectedItem().toString();
                String sql="select * from " + x;


                pst=conni.prepareStatement(sql);
                rs=pst.executeQuery();
                while(rs.next()){
                    String name = rs.getString("Namet");

                    nameofguy.setText(rs.getString(name));
                }

            }catch(Exception i){
                JOptionPane.showMessageDialog(null, i);

            }

我正在搜索 table.. 但它说找不到列。

这是你的问题

while(rs.next()){
   String name = rs.getString("Namet");
   //rs.getString returns Ayaan. So value of name is "Ayaan"
   nameofguy.setText(rs.getString(name));
   // Youre trying to get the value corresponding to the column Ayaan here
   //This is why the exception is thrown as there is no column called Ayaan
   }

改为

while(rs.next()){
   String name = rs.getString("Namet");
   nameofguy.setText(name);
   }