gpt4 book ai didi

java - HSQL 中的模式级序列

转载 作者:行者123 更新时间:2023-12-01 04:11:53 27 4
gpt4 key购买 nike

我在自动化组件测试中使用 HSQLDB 作为数据库。它模拟生产环境的 Oracle 数据库。

在我的 SQL 代码中,我在架构范围内定义了一个序列,例如

CREATE SEQUENCE THE_SCHEMA.THE_SEQUENCE ... ;

然后当我从这个模式中获取 nextval 时:

Connection con = ...
String query = "SELECT THE_SCHEMA.THE_SEQUENCE.nextval as MyNextVal from DUAL;"
PreparedStatement ps = con.prepareStatement(query);
ResultSet resultSet = ps.executeQuery();

我在 con.prepareStatement(query) 调用中收到如下错误。

当我在全局范围内定义序列时,上面的代码运行良好,如下所示

CREATE SEQUENCE THE_SEQUENCE ... ;

并改变

String query = "SELECT THE_SEQUENCE.nextval as MyNextVal from DUAL;"

我的问题是 HSQL 是否支持架构级别序列?

我错过了什么吗?

(我使用 SET DATABASE SQL SYNTAX ORA TRUE 打开了“Oracle 兼容模式”;)

堆栈跟踪:

Caused by: java.lang.NullPointerException
at org.hsqldb.RangeVariable.resolvesSchemaName(Unknown Source)
at org.hsqldb.RangeVariable.resolvesSchemaAndTableName(Unknown Source)
at org.hsqldb.RangeVariable.findColumn(Unknown Source)
at org.hsqldb.ExpressionColumn.resolveColumnReference(Unknown Source)
at org.hsqldb.ExpressionColumn.resolveColumnReferences(Unknown Source)
at org.hsqldb.QuerySpecification.resolveColumnReferencesAndAllocate(Unknown Source)
at org.hsqldb.QuerySpecification.resolveColumnReferences(Unknown Source)
at org.hsqldb.QuerySpecification.resolveReferences(Unknown Source)
at org.hsqldb.QueryExpression.resolve(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
... 26 more
java.sql.SQLException: java.lang.NullPointerException java.lang.NullPointerException
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)

有关 con.prepareStatement(query) 引发的异常的详细信息:

Exception type java.sql.SQLException
cause = org.hsqldb.HsqlException: java.lang.NullPointerException
detailMessage = java.lang.NullPointerException java.lang.NullPointerException
next = null
SQLState = S1000
stackTrace = null
vendorCode = -458

最佳答案

请从http://hsqldb.org/support/获取最新的HSQLDB快照jar并检查问题是否已解决。

关于java - HSQL 中的模式级序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19840362/

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