从MS Access数据库添加ComboBoxItem

时间:2013-11-19 08:46:44

标签: java

我正在尝试从数据库添加ComboxItem。我已经写了下面给出的代码。当我运行程序时,它会给出一条错误消息。

消息是 java.sql.SQLException:驱动程序不支持此功能

有人请帮帮我。

这是我的代码

public class DepositFirstForm extends javax.swing.JFrame {

    Connection conn=null;
    ResultSet rst=null;
    PreparedStatement pst=null;
    private void ItemComb(){

private void ItemComb(){

    String sql="SELECT * FROM account_type";

    try
    {
        pst=conn.prepareStatement(sql);
        rst=pst.executeQuery(sql);
         while(rst.next()){  

             String actype=rst.getString("account_type");
             dfcmb1.addItem(actype);

        } 


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

    }

}
private void formWindowOpened(java.awt.event.WindowEventevt)                           {                                  
    // TODO add your handling code here:
    conn=Connect.connectDB();
    ItemComb();


}

}

我的表名是account_type

serial_no   account_type

1       regular
2       premium
3       golden

1 个答案:

答案 0 :(得分:1)

尝试从调用pst.executeQuery:

中删除(sql)参数
rst = pst.executeQuery();

由于您已使用SQL创建PreparedStatement。 我相信你在某个地方宣布conn,pst和rst。

相关问题