Let's see what type of concurrency the JDBC driver returned - Java JDBC

Java examples for JDBC:ResultSet

Description

Let's see what type of concurrency the JDBC driver returned

Demo Code

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class Main {
  public static void main(String[] args) {
    try {//  ww  w.  ja va  2s  .c o m
      Connection conn = null;// JDBCUtil.getConnection();

      // Request a bidirectional change insensitive ResultSet
      // with concurrency as CONCUR_UPDATABLE
      Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
          ResultSet.CONCUR_UPDATABLE);

      String SQL = "your select statement goes here";

      // Get a result set
      ResultSet rs = stmt.executeQuery(SQL);

      // Let's see what type of concurrency the JDBC driver returned
      int concurrency = rs.getConcurrency();

      if (concurrency == ResultSet.CONCUR_READ_ONLY) {
        System.out.println("ResultSet is CONCUR_READ_ONLY");
      } else if (concurrency == ResultSet.CONCUR_UPDATABLE) {
        System.out.println("ResultSet is CONCUR_UPDATABLE");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Result


Related Tutorials