Oracle doesn't have the scrollable cursor support?

Whenever accessing Database I would highly recommend that you maintain a table cache of your own inside the program and traverse through the table within that cache.
 
Better not to use ResultSet and replace it with your own Data Structure. There are two reasons why this technique should be followed. First a ResultSet contains mostly redundant info as well and it occupies space in memory for all the time. Secondly most of the time ResultSet if bounded with Database itself and causing delay for extremely large tables, because of the rule of Thumb that HardDisk seek time is much greater than memory access time.
 
A custom data structure (a structure or class) can be very easy to implement since the table entries obtained from the ResultSet are mostly parsed as Strings.
 
We can use any of java.util.Vector or java.util.ArrayList. The ArrayList class is also available in C# under System.Collection.ArrayList.
 
For instance if you have a table like emp in oracle, than modify the following code:
 
   ArrayList tblTempCache = new ArrayList();   Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
   String url = "jdbc:odbc:blah";
   Connection conn = DriverManager.getConnection (url, "scott", "tiger");
   Statement stmet = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
   ResultSet.CONCUR_UPDATABLE);

   ResultSet rst = stmet.executeQuery ("select ename from emp");

   String entireRow[] = new String [rst.getMetaData().getColumnCount()];
   while (rst.next()){
    entireRow[0] = rst.getString(1);
//   entireRow[1] = rst.getString(2); // And so on till the number of columns
    System.out.println (rst.getString(1));
    tblTempCache.add( entireRow ); // adding to the custom cache
   }

How to Parse The table back and forth? Just use the index within the ArrayList
Collection Object.

   int rowNumber = 3; // the rowCount we need to get.
   String row[] = (String[])tblTempCache.get(3);   System.out.println(row[0]);//  System.out.println(row[1]); // And so on till the number of colums.
                 // Also the number of columns can be obtained by calling
                 // row.length;
 

I was unable to run the code as I am not having Oracle with me at the moment. I hope that the above explaination will suffice.

Comments

Popular posts from this blog

Imote2 with Camera setup IMB400 over Ubuntu 9.10/10.04

Branch and bound algorithm in C#- Article by AsiF Munir

Tensorflow - Simplest Gradient Descent using GradientDescentOptimizer