This question already has answers here:
How do I fix a NoSuchMethodError?
                                
                                    (28个答案)
                                
                        
                                3年前关闭。
            
                    
我正在尝试使用UCanAccess更新MS Access数据库中的记录,但在尝试执行此操作时收到此消息:


  net.ucanaccess.jdbc.UcanaccessSQLException:UCAExc ::: 3.0.5
  java.lang.NoSuchMethodError:
  com.healthmarketscience.jackcess.Table.isAllowAutoNumberInsert()Z


码:

public void saveBookInfo(){
    try {
        Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
        Connection connectDb = DriverManager.getConnection("jdbc:ucanaccess://books.mdb");

        String sql = "UPDATE bookInfo SET bookName=?, companyName=?, bossName=?, bossPosition=?, developerName=?, developerCompanyName=? WHERE bookId=?";

        PreparedStatement pstmt = connectDb.prepareStatement(sql2);
        pstmt.setString(1, jTextField2.getText());
        pstmt.setString(2, jTextField3.getText());
        pstmt.setString(3, jTextField4.getText());
        pstmt.setString(4, jTextField5.getText());
        pstmt.setString(5, jTextField6.getText());
        pstmt.setString(6, jTextField7.getText());
        pstmt.setInt(7, currentBookId);

        pstmt.executeUpdate();
        System.out.println("\nSuccess!");

        closeSC(pstmt, connectDb);

    } catch (Exception ex) {
        System.out.println("\nException (saveBookInfo): " + ex);
    }
}


有人知道问题出在哪里吗?

(删除查询工作正常)

最佳答案

汤普森(Gord Thompson)回答:

“验证您的项目正在使用Jackcess 2.1.3版本。请注意,在UCanAccess发行版的lib文件夹中有“ jackcess-2.1.3.jar”。

10-05 23:39