UCAExc:::4.0.4 尝试分配给不可更新的列

UCAExc:::4.0.4 attempt to assign to non-updatable column

This is a link to a sample database I would like this code to connect to my database and encrypt the rows within the table "WellTable" unfortunately I am getting an error listed below. I have followed the guide here: Manipulating an Access database from Java without ODBC ...我正在使用 Atom IDE。

import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.util.Scanner;
import java.sql.*;
/*import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
*/


public class hippa {
  public static void main(String[] args) {
        //String databaseURL = "jdbc:ucanaccess://C:/Users/al3cz/OneDrive/Desktop/hippaProject/WellnessMerge.accdb";
        String passkey = ""; // field for passkey
        int dctnum = 0; //dct loop number
        final String key = "Pass1234Pass1234"; // 128 bit key
        String ID = "";
        int x = 0;

        try {

          //connect to the database and get ID
            Connection dbConnection = DriverManager.getConnection("jdbc:ucanaccess://C:/Users/al3cz/OneDrive/Desktop/hippaProject/WellnessMerge.accdb");
            Statement readID = dbConnection.createStatement();
            String sql = "SELECT [CID] FROM [WellTable]";
            ResultSet rs = readID.executeQuery(sql);
            while (rs.next()) {
                 ID = rs.getString("CID");

                //ID = "863784593";

                // Create key and cipher
                Key aesKey = new SecretKeySpec(key.getBytes(), "AES");
                Cipher cipher = Cipher.getInstance("AES");

                //TODO create GUI button that Encrypts all IDs
                // encrypts the ID
                cipher.init(Cipher.ENCRYPT_MODE, aesKey);
                byte[] encryptedID = cipher.doFinal(ID.getBytes());
                StringBuilder sb = new StringBuilder();
                for (byte b: encryptedID) {
                    sb.append((char)b);
                }
                // print the encrypted ID
                String encID = sb.toString();
              //  System.out.println("encrypted ID:" + encID);
                rs.updateString("CID", encID);
                x++;


                // convert the ID to byte array for decryption
                byte[] bb = new byte[encID.length()];
                for (int i=0; i<encID.length(); i++) {
                    bb[i] = (byte) encID.charAt(i);
                }
            }
            System.out.println("This plugin has encrypted " + x +" ID(s)");

            //decrypts the ID
            //TODO create GUI button that Decrypts current IDs or all IDs
            /*
            Scanner keyboard = new Scanner(System.in);
            do {
                System.out.println("Enter the password to decrypt database");
                passkey = keyboard.nextLine();
                if (passkey.equals(key)){
                    dctnum = 7153;
                    cipher.init(Cipher.DECRYPT_MODE, aesKey);
                    String decrypted = new String(cipher.doFinal(bb));
                    System.out.println("decrypted ID:" + decrypted); //TODO insert way to reverse updateID
                }else {System.err.println("incorrect passkey, encrypted ID remains");}
             } while (dctnum != 7153);
             */
        }

        catch(Exception e){
            e.printStackTrace();
        }
  }
}

This code gives an error :  4.0.4 attempt to assign to non-updatable column
        at net.ucanaccess.jdbc.UcanaccessResultSet.updateString(UcanaccessResultSet.java:1924)

现在你有一个可以回答的问题:

如果您阅读 java.sql.Connection.createStatement() 的文档,您会看到:

Result sets created using the returned Statementobject will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

因此,要使其可更新,您必须使用另一个构造函数来更改它:

Statement readID = dbConnection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);

的副本