简体   繁体   English

创建带有自动增量列的表:'' 不是有效名称

[英]Creating a table with autoincrement column: '' is not a valid name

I use UCanAccess (4.0.2) to create a new file with a single table like this:我使用 UCanAccess (4.0.2) 创建一个带有单个表的新文件,如下所示:

// 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);

The code works but the resulting table seems to be incomplete/flawed.代码有效,但结果表似乎不完整/有缺陷。 Trying to copy it in Access results in an error:尝试在 Access 中复制它会导致错误:

'' is not a valid name... '' 不是一个有效的名称...

Doesn't seem to be a big problem as saving the table from the design view solves it.似乎不是什么大问题,因为从设计视图中保存表格可以解决这个问题。

Any idea why that happens and how to avoid it?知道为什么会发生这种情况以及如何避免吗?

This is related to a confirmed issue with Jackcess versions 2.1.8 and older.这与 Jackcess 2.1.8 及更早版本的已确认问题有关。 A fix has been applied to Jackcess that will be included in the next release (tentatively 2.1.9).已对 Jackcess 应用了一个修复程序,修复程序将包含在下一个版本(暂定为 2.1.9)中。 Once a UCanAccess update is released that includes the Jackcess fix then the problem should go away.一旦发布了包含 Jackcess 修复程序的 UCanAccess 更新,问题就会消失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM