Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Creating a SCROLL_INSENSITIVE ResultSet using SAP Hana JDBC Driver

$
0
0
public static void main(String[] args) throws ClassNotFoundException {        // TODO code application logic here                Class.forName("com.sap.db.jdbc.Driver");                String myname = "USERNAME";        String mysecret = "PASSWORD";                        Connection connection = null;      try {                           connection = DriverManager.getConnection("jdbc:sap://URL:PORT/?autocommit=false",myname,mysecret);                        } catch (SQLException e) {         e.printStackTrace();         return;      }      if (connection != null) {         try {            System.out.println("Connection to HANA successful!");             java.sql.Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);             java.sql.ResultSet resultSet = stmt.executeQuery("SQL QUERY HERE");            String hello = resultSet.getString(1);            System.out.println(hello);       } catch (SQLException e) {          e.printStackTrace();       }     }                    }

When I run the above program I get the following exception at Line number 20:

 

com.sap.db.jdbc.exceptions.jdbc40.SQLDataException: Invalid argument resultSetType, use TYPE_FORWARD_ONLY.

 

If I replace Line number 20 with:

 

java.sql.Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

It works without an error. But I need the ResultSet to be able to scroll both ways so that I can use methods such as getRow, previous and last.

 

What am I doing wrong? The above code works perfectly well for MySQL, Microsoft SQL, Oracle and TeraData. How do I achieve this in SAP Hana?


Viewing all articles
Browse latest Browse all 6412

Trending Articles