开发者

Scrollable ResultSet JDBC Postgresql

开发者 https://www.devze.com 2023-01-27 03:17 出处:网络
When I create a prepared statement like this in java (using JDBC): pStmt = conn.prepareStatement(qry);

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


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)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号