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

喜你入骨 提交于 2019-12-14 02:40:14

问题


I use UCanAccess (4.0.2) to create a new file with a single table like this:

// 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:

'' 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?


回答1:


This is related to a confirmed issue with Jackcess versions 2.1.8 and older. A fix has been applied to Jackcess that will be included in the next release (tentatively 2.1.9). Once a UCanAccess update is released that includes the Jackcess fix then the problem should go away.



来源:https://stackoverflow.com/questions/46405841/creating-a-table-with-autoincrement-column-is-not-a-valid-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!