可滚动结果集 JDBC Postgresql

发布于 2024-10-04 18:15:46 字数 639 浏览 0 评论 0原文

当我在 java 中创建这样的准备好的语句(使用 JDBC)时:

pStmt = conn.prepareStatement(qry);

一切正常。但是,当我想要一个可滚动的结果集并使用它时:

pStmt = conn.prepareStatement(qry,ResultSet.TYPE_SCROLL_INSENSITIVE);

我收到语法错误:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"

我什至没有在查询中使用 RETURNING。

有什么想法吗?

任何帮助将不胜感激。谢谢

更新: 如果我使用这个似乎可行:

pStmt = db.prepareStatement(qry,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

SENSITIVE 和 INSENSITIVE 之间有什么区别?

谢谢

When I create a prepared statement like this in java (using JDBC):

pStmt = conn.prepareStatement(qry);

everything works ok. However when I want a scrollable resultset and use this:

pStmt = conn.prepareStatement(qry,ResultSet.TYPE_SCROLL_INSENSITIVE);

I get a syntax error:

org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"

I'm not even using RETURNING in my query.

Any ideas?

Any help would be appreciated. Thanks

Update:
It seems to work if I use this:

pStmt = db.prepareStatement(qry,ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

What is the difference between SENSITIVE and INSENSITIVE?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北渚 2024-10-11 18:15:46

prepareStatement 的第二个参数应该是 Statement.RETURN_GENERATED_KEYS 或 Statement.NO_GENERATED_KEYS 之一。

我猜你想用

PreparedStatement prepareStatement(String sql,
                                   int resultSetType,
                                   int resultSetConcurrency)

The second parameter to prepareStatement should be one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS.

I guess you want to use

PreparedStatement prepareStatement(String sql,
                                   int resultSetType,
                                   int resultSetConcurrency)
我不是你的备胎 2024-10-11 18:15:46

ResultSet.TYPE_SCROLL_INSENSITIVE :假设结果集不“感知”执行查询后发生的数据库更改。

ResultSet.TYPE_SCROLL_SENSITIVE :获取执行查询后数据库中发生的更改

ResultSet.TYPE_SCROLL_INSENSITIVE : This assumes that the result set does not “sense” database changes that occurred after execution of the query.

ResultSet.TYPE_SCROLL_SENSITIVE : picks up changes in the database that occurred after execution of the query

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文