gpt4 book ai didi

java - H2 数据库在 CREATE SEQUENCE 上抛出意外的 JdbcSQLException

转载 作者:行者123 更新时间:2023-12-02 02:25:41 29 4
gpt4 key购买 nike

我正在尝试编写一个内存数据库来测试我的 DAO 对象。我得到以下堆栈跟踪:

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement " CREATE SEQUENCE CE0AOFQ AS[*] BIGINT START WITH 1 INCREMENT BY 1"; SQL statement:
CREATE SEQUENCE CE0AOFQ AS BIGINT START WITH 1 INCREMENT BY 1 [42000-196]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.getSyntaxError(DbException.java:191)
at org.h2.command.Parser.getSyntaxError(Parser.java:534)
at org.h2.command.Parser.prepareCommand(Parser.java:261)
at org.h2.engine.Session.prepareLocal(Session.java:578)
at org.h2.engine.Session.prepareCommand(Session.java:519)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1204)
at org.h2.jdbc.JdbcStatement.executeUpdateInternal(JdbcStatement.java:132)
at org.h2.jdbc.JdbcStatement.executeUpdate(JdbcStatement.java:121)
at org.springframework.jdbc.datasource.init.ResourceDatabasePopulator.executeSqlScript(ResourceDatabasePopulator.java:169)

当尝试在名为 init.sql 的文件中执行此命令时:

CREATE SEQUENCE CE0AOFQ AS BIGINT START WITH 1 INCREMENT BY 1;

据我检查(例如 here ),此查询似乎是正确的。

知道为什么这不起作用吗?

最佳答案

您无法在 h2 中指定序列的数据类型。它始终是 BIGINT。

用途:

CREATE SEQUENCE CE0AOFQ START WITH 1 INCREMENT BY 1;

关于java - H2 数据库在 CREATE SEQUENCE 上抛出意外的 JdbcSQLException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47809974/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com