'has UCanAccess any mechanism to write in-memory data to .accdb file in a java desktop application?

i'm losing new data that i made when i close my Java app and data are not written to .accdb file
i have connected my Java to .accdb (Ms Access 2010) file as below using UCanAccess:

Connection c;
File file = new File("src/main/resources/com/pointage/db/pointage.accdb");
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
c = DriverManager.getConnection("jdbc:ucanaccess://" + file.getAbsolutePath());


i've used instruction like i'm used to do with mariadb or MySQL :

c.createStatement().executeQuery(SQL);

when i found that data are lost when closing the app, i searched and found that people are using PreparedStatement.executeQuery() and PreparedStatement.executeUpdate() methods so i used them also :

 public ResultSet executeQuery(String SQL) {
        ResultSet rs = null;
        try {
            Statement st = c.createStatement();
            PreparedStatement ps = c.prepareStatement(SQL);
            if (SQL.toUpperCase().startsWith("SELECT")) rs = ps.executeQuery(); // reading data is normal, and can read old and new data
            else ps.executeUpdate(); // ps.executeQuery(); manipulated data( inserted or edited or deleted) is staying in-memory only
            // c.commit(); not sure about this one if can do anything
            System.out.println("\nexecuted successfully : " + SQL.toUpperCase().split(" ")[0] + "\n" + SQL);
        } catch (SQLException e) {
            System.out.println("\nexecution failed : \n SQL :" + SQL + "\nCause :" + e.getCause());
        }
        return rs;
    }

but nothing changed and data are lost each time i stop the app
Note: when i restart my app i got the data that were inserted (edited or deleted) last time using Ms Access 2010

  • .accdb file created using MS-Access 2010 in windows then transferred to project directory in Linux.
  • App development in Arch Linux using Intellij IDEA.
  • GitHub repo


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source