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
Now, as we have mentioned, we can scroll through records with the help of the ResultSet object. But, this ability does not come by default. The default behavior of the ResultSet object is that it is not updatable and the cursor it owns actually moves in one direction, forward only.
The main difference between scrollable and non scrollable cursors in DB2 is that scrollable cursors are used to move randomly through the result set while non-scrollable cursors are used to move sequentially forward through the result set.
You can create a Statement that returns result sets in one of the following types: - TYPE_FORWARD_ONLY: the result set is not scrollable (default). - TYPE_SCROLL_INSENSITIVE: the result set is scrollable but not sensitive to database changes.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With