This is a follow-up to this this question. The error is a bit different with the new UCanAccess version now.
这是对这个问题的后续跟进。现在,新的UCanAccess版本的错误有点不同。
I create a database file with a table containing a NOT-NULL column using the latest UCanAccess (4.0.3, including Jackcess 2.1.9) like this
我使用最新的UCanAccess(4.0.3,包括Jackcess 2.1.9)创建一个包含NOT-NULL列的表的数据库文件
// Create a database + connect
DatabaseBuilder.create(FileFormat.V2010, new File(path));
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
conn = DriverManager.getConnection("jdbc:ucanaccess://" + path + ";singleconnection=true" ,"", "");
// Create table
String sql = "CREATE TABLE Test (id AUTOINCREMENT PRIMARY KEY, value CHAR(1) NOT NULL)";
conn.createStatement().executeUpdate(sql);
Trying to insert values works fine via UCanAccess, NULL is rejected for the column 'value' by UCanAccess as expected. However, when I use the table in Access directly, NULL is accepted! Working with the data via UCanAccess later leads to problems as the table cannot be written to:
尝试插入值通过UCanAccess正常工作,UCanAccess按预期拒绝NULL'列'值'。但是,当我直接在Access中使用表时,接受NULL!之后通过UCanAccess处理数据会导致问题,因为无法将表写入:
WARNING:Detected Not Null constraint breach, table Test, record Row[87:1][{id=2,value=}]: making the table Test readonly
警告:检测到非空约束违规,表测试,记录行[87:1] [{id = 2,value =}]:使表格只读测试
Opening and saving the table from the design view in Access solves the problem, but is not an option on the long run. How to make Access respect the NOT-NULL constraint?
从Access中的设计视图打开和保存表可以解决问题,但从长远来看不是一个选项。如何使Access尊重NOT-NULL约束?
1 个解决方案
#1
2
This has been traced to a known issue with Jackcess 2.1.10. It should be fixed in upcoming releases of Jackcess and UCanAccess, respectively.
这可以追溯到Jackcess 2.1.10的一个已知问题。它应该分别在即将发布的Jackcess和UCanAccess版本中修复。
#1
2
This has been traced to a known issue with Jackcess 2.1.10. It should be fixed in upcoming releases of Jackcess and UCanAccess, respectively.
这可以追溯到Jackcess 2.1.10的一个已知问题。它应该分别在即将发布的Jackcess和UCanAccess版本中修复。