有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

从MS Access数据库添加java ComboBoxItem

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

信息是 JAVAsql。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();


}

}

我的表名是帐户类型

serial_no   account_type

1       regular
2       premium
3       golden

共 (1) 个答案

  1. # 1 楼答案

    尝试从pst调用中删除(sql)参数。执行:

    rst = pst.executeQuery();
    

    因为您的PreparedStatement已经使用SQL创建。 我相信你在某处申报conn、pst和rst