I'm trying to create a Scroll_Insensitive ResultSet using/in the SAP Hana JDBC Driver. When I run the below code:
Class.forName("com.sap.db.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:sap://10.32.86.10:30115/autocommit=false",username,password);
java.sql.Statement stmt = connection.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, java.sql.ResultSet.CONCUR_READ_ONLY);
java.sql.ResultSet resultSet = stmt.executeQuery("SELECT * FROM SAMPLE");
resultSet.next();
String hello = resultSet.getString(1);
I get the following exception:
com.sap.db.jdbc.exceptions.jdbc40.SQLDataException: Invalid argument resultSetType, use TYPE_FORWARD_ONLY.
If I replace the third line with:
java.sql.Statement stmt = connection.createStatement();
It works without a hitch. I need the ResultSet to be Scroll_Insensitive to be able to use methods such as
rs.previous(), rs.last(), rs.getRow(), etc.
The same code works perfectly for MySQL, Microsoft SQL, TeraData & Oracle. What might the problem with SAP Hana? Is there a workaround?
The answer simply is what the error message implies: SAP HANA's JDBC driver (currently) only provides you with a FORWARD ONLY cursor type.
Question here would be what specific characteristic of the TYPE_SCROLL_INSENSITIVE cursor type do you actually need here?