我试图在插入连接表时检索connection_id 列。我在应用程序启动时生成了一个表,如下所示,column_id 是自动生成的。
CREATE TABLE connections (connection_ID INT not null primary key GENERATED ALWAYS AS IDENTITY(START WITH 1, INCREMENT BY 1),
connection_name VARCHAR(100) unique not null, user_name VARCHAR(100) not null, password VARCHAR (100) not null, server_url
VARCHAR(100) not null, port_number VARCHAR(10) not null),
我使用以下语句来检索connection_ids的liat
PreparedStatement stmt = dbconn.prepareStatement(insertString, new String[] {"connection_id"});
但是即使我的connection_id是自动生成的,我也会收到以下异常,
java.sql.SQLException: Table 'CONNECTIONS' does not have an auto-generated column named 'connection_id'.
最佳答案
我对 Java DB 没有太多经验,但希望这会有所帮助。
也许您需要的是使自动生成的 key 可返回。检查Java DB Reference Manual和 Connection class definition
关于java.sql.SQLException : Table 'CONNECTIONS' does not have an auto-generated column named 'connection_id' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7914435/