Java API Tutorial - Java ResultSet.getType()








Syntax

ResultSet.getType() has the following syntax.

int getType()  throws SQLException

Example

In the following code shows how to use ResultSet.getType() method.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
//  w  w  w  . j a  v  a 2 s  .co  m
public class Main {

  public static void main(String[] args) throws Exception {
    try {
      String url = "jdbc:odbc:yourdatabasename";
      String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
      String user = "guest";
      String password = "guest";

      Class.forName(driver);
      Connection connection = DriverManager.getConnection(url, user, password);
      Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
          ResultSet.CONCUR_READ_ONLY);

      ResultSet rs = stmt.executeQuery("SELECT * from DUMMY");

      System.out.println(rs.getType());
      System.out.println(rs.getConcurrency());

      rs.deleteRow();
      rs.close();

      rs.close();
      stmt.close();
      connection.close();
    } catch (Exception e) {
      System.err.println(e);
    }
  }
}