Java 从Dropwizard应用程序自动增加Postgres

Java 从Dropwizard应用程序自动增加Postgres,java,postgresql,dropwizard,Java,Postgresql,Dropwizard,我正在将dropwizard应用程序与Postgres db连接。我在启动应用服务器时动态创建表 private static void createTableUser(Connection connection) throws SQLException { Statement statement= connection.createStatement(); statement.executeUpdate("CREATE TABLE USERR" +"("

我正在将dropwizard应用程序与Postgres db连接。我在启动应用服务器时动态创建表

private static void createTableUser(Connection connection) throws SQLException {
    Statement statement= connection.createStatement();
    statement.executeUpdate("CREATE TABLE USERR"
            +"("+
            "id INTEGER,"+
            "first_name VARCHAR(20),"+
            "middle_name VARCHAR(20),"+
            "last_name VARCHAR(20),"+
            "age INTEGER,"+
            "image_url VARCHAR(250),"+
            "joining_date DATE ,"+
            "country_code INTEGER,"+
            "mobile_no VARCHAR(20),"+
            "email_id VARCHAR(20),"+
            "CONSTRAINT pk_user PRIMARY KEY (id)"+
            ")"
    );
    statement.close();
}
上面是创建我的表的函数。这样它工作得很好。但我想让id自动递增。我浏览了一些文章,这些文章给出了关键字SERIAL、bigsserial、SMALLSERIAL的建议

当我使用sql server时,我就是这样做的

id INTEGER IDENTITY (1)
在这里,身份也可用作选项,但当我尝试它时,我得到了错误

Exception in thread "main" org.postgresql.util.PSQLException: ERROR: syntax error at or near "IDENTITY"
有人能帮我吗? 提前感谢

是的,建议使用id序列号


Postgres中没有标识,因此使用串行列将自动创建一个用于填充值的序列,给出相同的行为。

实际上,Postgres 10中的标识列与SQL标准中定义的方式相同,而不是SQL Server使用它们的方式。@a_horse_没有名称啊,你说得对,我也读了10年的发行说明。。。