What is ResultSet Concurrency in JDBC?


The concurrency of the ResultSet object determines whether its contents can be updated or not.

The Connection interface provides 3 variants of the createStatement() method where one of the method's signature is as follows:

Statement createStatement(int resultSetType, int resultSetConcurrency)

This method accepts two integer type variables where one represents the type of the ResultSet and the other represents the Concurrency of the ResultSet.

The ResultSet interface provides two values to specify the concurrency of the ResultSet.

  • CONCUR_READ_ONLY: If you set this as a value of the concurrency while creating the ResultSet object you cannot update the contents of the ResultSet you can only read/retrieve them.

  • CONCUR_UPDATABLE: If you set this as a value of the concurrency while creating the ResultSet object you can update the contents of the ResultSet.

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
Or,
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.
ResultSet.CONCUR_UPDATABLE);

Updated on: 30-Jul-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements