可滚动结果集 JDBC Postgresql
当我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
prepareStatement 的第二个参数应该是 Statement.RETURN_GENERATED_KEYS 或 Statement.NO_GENERATED_KEYS 之一。
我猜你想用
The second parameter to prepareStatement should be one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS.
I guess you want to use
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