Note that there are some explanatory texts on larger screens.

plurals
  1. POJAVA ODBC scroll error despite TYPE_SCROLL_SENSITIVE
    primarykey
    data
    text
    <p>I have a JAVA project involving a ODBC database query in which I need to move the cursor in the result set. I've declared the type of <code>ResultSet</code> to be <code>TYPE_SCROLL_SENSITIVE</code>, but when I execute the script I get an exception stating the <code>ResultSet</code> type is <code>TYPE_FORWARD_ONLY</code>. I've pasted my (simplified) project code below, and would appreciate any help.</p> <pre><code>import java.util.InputMismatchException; //Necessary package for basic Java utilities import java.sql.*; //Necessary packages for SQL routines public class test { public static void main(java.lang.String[] args) throws Exception { // declare variables &amp; create database connection System.out.println("Open ODBC Connection...."); Connection dataConnection = DriverManager.getConnection("jdbc:odbc:DSN"); Statement stmt = dataConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); int i = 0; int N = 0; //loading JDBC-ODBC Bridge driver into memory Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // create SQL query string String sql = "SELECT ObjRef, IDX, DateListDateAsString FROM ARRAY_BAC_CAL_DateList WHERE DEV_ID=10000 AND INSTANCE=1"; // run the query ResultSet rs = stmt.executeQuery(sql); // determine number of date entries rs.last(); N = rs.getInt("IDX"); // close connection rs.close(); dataConnection.close(); System.out.println ("Connection closed\n"); } } </code></pre> <p>The error I receive is:</p> <blockquote> <p>"Exception in thread "main" java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY at sun.jdbc.odbc.JdbcOdbcResultSet.last(JdbcOdbcResultSet.java:2290) at test.main(test.java:26)</p> </blockquote> <p>Line 26 is where I try to move the result set cursor.</p> <p>Again, any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload