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

消息是
java.sql.SQLException:Driver不支持此功能

有人请帮助我。

这是我的代码

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

最佳答案

尝试从对pst.executeQuery的调用中删除(sql)参数:

rst = pst.executeQuery();


由于您的PreparedStatement已经使用SQL创建。
我相信您在某个地方声明了conn,pst和rst。

关于java - 从MS Access数据库添加ComboBoxItem,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20066887/

10-10 23:14
查看更多