ResultSet.absolute(int) performance

Hi,
we are experiencing some horrible performance using the absolute() method on a ResultSet. I am aware Oracle only natively supports forward only cursors, but I wonder if anyone has some workaround for getting "acceptable" speeds from this method. On a local database with ~15.000 results in a rather simple query absolute() takes 5032 ms, quite a bit for a user waiting :-)
The senario is a window with a scrollbar, the scrollbar is decoupled in the sense it's just a standard JScrollBar. The user has made a search and have maybe gotten 15.000 results, now the user wants to drag the scrollbar so it maybe ends up in what corresponds to entry 14.500 in the ResultSet. Behind the sceens we then invoke ResultSet.absolute(14500), load the data and displays it. The above mentioned ~5000 ms is unfortunately what takes the time in this operation.
We're using Oracle 9.2.0.1.0, JDK 1.4.22_01-b06 with the thin driver found in ojdbc14.jar downloaded as newest version here from OTN. 3rd party driver suggestions are welcome but they must support somewhat complex queries across multiple table.
Best regards
Jan Jonasen

Thanks for your replies. I'll look for the patch initially.
Don't worry, we're not showing 15.000+ results at the same time :-) It's thumbnails showing images, so a user with a huge window will maybe have shown 100, but that is a bit high set. In reality it's only the result which very much like Google will contain a lot of hits, but only those which fit in the window are actually shown. Also, the reference to the scrollbar is just to simplify the example, so I'll elaborate a bit.
A user performs a search given no arguments which results in everything from the relevant tabel in the database gets a hit, for the example of my local development one it's 15.000, customers usually have quite a bit more. In the end only whatever there's room for is extracted from the result, during "normal" circumstances this may be 25 tops, much like you would see on a search engine on the web. If the user pushes the arrow on the scrollbar, the next row for the window is loaded, again "normally" this would be maybe 5 additional results. Pressing page down/up on the comparable function of the scrollbar fills the page with the next 25 which may mean going 25 forward or backward in the original search result. Since it's a scrollbar the user can also drag in to some position, so for the example the user drags to what corresponds to 14.000 in the search result. It can somewhat be compared to Google supplying a "Go to page" in your query.
Both going forward/backward and "jumping" to 14.000 means the usage of ResultSet.absolute(), which is as said terrible slow I guess because of forward only cursors.
It's actually not fetching the data which takes the time, it's the usage of ResultSet.absolute(), having timed it, the call takes 5000+ ms, so I'm looking for a workaround or well, anything to help solve this slowness.
For instance have anyone tried showing a "SELECT * FROM table" (result 10.000+) and enabled the user to jump to any row? How did you manage that?

Similar Messages

  • ResultSet.absolute(int) Performance Issue

    I'm using the Oracle driver. I've run some tests and it appears that:
    ResultSet rs = ...;
    rs.absolute(n);
    has approximately the same performance as:
    ResultSet rs = ...;
    for (int i = 0; i < n; i++)
    rs.next();
    Is this all it is doing? For large values of "n" this could be very bad.
    I'd use "ROWNUM", but I also use an O/R framework. The only way to
    pull out specific subsets is to use JDBC scrolling. Is there anything I
    can do?
    Thanks,
    Bob

    Bob Lee wrote:
    There are at least 4 oracle driver vendors and
    multiple versions from each, so let us know
    which one you're using. See more below...I've tried the Oracle OCI (thick) and thin drivers, version 9.
    It certainly may be doing this. Very few drivers would go to the
    DBMS for each row individually, in a random access fashion.
    The driver would probably obtain and buffer all the intermediate
    rows that had not been fetched.This sucks. If I call ResultSet.absolute(), I probably don't need all of
    the intermediate rows.But you asked for them, so the driver and DBMS think you probably
    want them. Absolute() is part of implementing random access. It would
    never be interpreted as 'I don't want (some) rows'. It can be called to
    go backwards from the current position too.
    Clever SQL can be made to select the subsets (contiguous ranges) you want, one by oneDamn.It's a solution.... This sounds like something you want to do in a stored procedure.
    The cardinal performance problem in RDBMS applications is shipping scads of
    raw data out of the DBMS to the client, to be processed and/or discarded, instead
    of processing the raw stuff where it is in the DBMS.
    Good luck,
    Joe
    >
    Thanks,
    Bob
    Thanks,
    Bob

  • CreateStatement(int, int) performance

    Hi, I have some performance problems with the method createStatement(int, int) when using it on large tables (containing about 2,000,000 records). Does anyone already had the same prob?
    I use the createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)
    The DB used is DB2/400 on IBM iSeries.
    How is that method implemented? Does it fetch all elements??? Does it creates temp indexes??? I'm forced to use that method to be able to use a ResultSet.absolute(int) after...
    I've read somewhere that depending on the JDBC driver, we better use a count(*) in the sql query than a ResultSet.last() then ResultSet.getRow() because the last() will fetch all records. Maybe is it the same problem?
    Or maybe does anyone know if there's an equivalent of the absolute(int) in sql?
    Could anyone help me to find a solution for better performances?

    Indeed my question was not very clear sorry.
    Here's the context :
    In a web app, a user wants to make a search on client members, let's say the table has about 2,000,000 records of data.
    I have to display a page navigation system, let's say the user can display 50 records by page. He must be able to navigate through page 1 to the last page back and forward and with a step of 2 or more, and he can always reach the first and last page in a single click.
    That's why I used a scrollable ResultSet so I could use the rs.absolute(i) to position the cursor on the page I want to display, instead of doing rs.next() until I reach the correct position.
    That system works fine as long as there's not too much records. But unfortunately, some search without any criteria can give the total table, and I'm not in position to say there must be restriction on the search. The client is king.
    So I just wondered if there's a solution with good performance to doing so?
    My english is not very fluent so I hope it's understable ^^

  • ResultSet.getString(int) sometimes slow

    I'm working on an app that I'm attempting to optimize using JProfiler. In the course of inspecting how the time is being devided up, I noticed that there is one place in the code where ResultSet.getString(int) is taking much longer than it does in other areas. Usually, it averages anywhere from almost 0 ms to 0.01 ms per call. However, at one specific area, it's averaged anywhere from 7 to 45 ms per call. I can't find anything that sets it apart from any other calls to getResultSet() -- it happens to be averaged over several hundred rows, whereas the other, quicker calls are occurring when there's anywhere from 1 to tens of thousands of rows, so I can't see how the amount of data would have that affect. The result set is being pulled back along with several others from a single statement execution that has several queries, so they should all have the same fetch size. Does anyone have any ideas on what could cause a call to getString(int) at one specific place in the code to be 3-4 orders of magnitude slower than the others?
    Thanks for any help...

    I think you'd have to examine more of what is going on internally in the result set.
    As you mentioned fetch size could be something. It could be the particular type of column for which you are calling getString on.
    It could be a lot of things. There isn't really any answer for this other than to look at what your particular Result Set implementation is actually doing.

  • ResultSet.absolute(3) is not working.

    hi friends,
    I am using jdk1.3 and in my code im connecting to some
    DSN and when i use the method ResultSet.absolute(3)
    in my code, it says "feature is not supported".
    Any suggestions.
    thx in adv,
    kiran

    You mention DSN - you seem to use JDBC-ODBC then.
    The JDBC features you can with JDBC-ODBC bridge depend on the capabilities of the underlying ODBC driver.
    In many cases these drivers don't dupport the SCROLLABLE result sets.
    Either try to update your ODBC driver (new version of DLLs - for MS ODBC drivers new MDAC version) or use another ODBC DBMS or use a type 3 or 4 driver - or simply don't use this feature.

  • A question about ResultSet.UpdateObject(int column, Object x)

    hi, I write some code which use the TableModel to represent the data fetched from MS-ACCESS.
    the problem is about the UpdateObject(...) method which is in the implement of the AbstractTableModel method setAtValue(). when transfered OBJECT TYPE is java.lang.String, I can't get the correct result in the JTable view.
    my code is as below, could somebody point me out my problem
    public class MyTableModel extends AbstractTableModel {
        private ResultSet rs ;
        private ResultSetMetaData rsmd;
        /** Creates a new instance of MyTableModel */
        public MyTableModel() {
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            String url = "jdbc:odbc:CoffeeBreak";
            try {
                Connection con = DriverManager.getConnection(url,"","");
                String strSQL = "SELECT * FROM COFFEES";
                Statement pSt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
                rs = pSt.executeQuery(strSQL);
                rsmd = rs.getMetaData();
            } catch (SQLException ex) {
                ex.printStackTrace();
    /* table model retrieve the Class type of a column method here*/
    public Class getColumnClass(int c){
            try {
                return Class.forName(rsmd.getColumnClassName(c+1));
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return String.class;
    //method of update database and JTable after user edited a table cell
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            try {
                int concurrency = rs.getConcurrency();
                if(concurrency == 1008){
                    rs.absolute(rowIndex+1);    //the JTable row index is start from 0,so plus 1
                    rs.updateObject(columnIndex+1, aValue);//the JTable column index is start from 0, so plus 1
                    rs.updateRow();
            } catch (SQLException ex) {
                ex.printStackTrace();
        }when the column type is about java.lang.String, the cell's result is incorrect, it looks like "[B@1f8f72f" and database can't update.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    It's me again.
    I post the whole class code here
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.AbstractTableModel;
    * @author qhj
    public class MyTableModel extends AbstractTableModel {
        /** Creates a new instance of MyTableModel */
        private ResultSet rs ;
        private ResultSetMetaData rsmd;
        private Statement pSt;
        private String strSQL;
        public MyTableModel() {
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            String url = "jdbc:odbc:CoffeeBreak";
            try {
                Connection con = DriverManager.getConnection(url,"","");
                strSQL = "SELECT * FROM COFFEES";
                pSt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
                rs = pSt.executeQuery(strSQL);
                rsmd = rs.getMetaData();
            } catch (SQLException ex) {
                ex.printStackTrace();
        public int getRowCount() {
            try {
                rs.last();
                return rs.getRow();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return 0;
        public int getColumnCount() {
            try {
                return rsmd.getColumnCount();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return 0;
        public Object getValueAt(int rowIndex, int columnIndex) {
            try {
                rs.absolute(rowIndex+1);
                return rs.getObject(columnIndex+1);
            } catch (SQLException ex) {
                ex.printStackTrace();
            return null;
        public String getColumnName(int column){
            try {
                return rsmd.getColumnName(column+1);
            } catch (SQLException ex) {
                ex.printStackTrace();
            return "N/A";
        public Class getColumnClass(int c){
            try {
                return Class.forName(rsmd.getColumnClassName(c+1));
            } catch (ClassNotFoundException ex) {
                ex.printStackTrace();
            } catch (SQLException ex) {
                ex.printStackTrace();
            return String.class;
        public boolean isCellEditable(int row, int col) {
            //Note that the data/cell address is constant,
            //no matter where the cell appears onscreen.
            return true;
        public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
            try {
                int concurrency = rs.getConcurrency();
                if(concurrency == 1008){
                    rs.absolute(rowIndex+1);
                    rs.updateObject(columnIndex+1, aValue);
                    //rs.updateRow();
                    //rs = pSt.executeQuery(strSQL);
            } catch (SQLException ex) {
                ex.printStackTrace();
            fireTableDataChanged();
    }

  • Resultset (absolute) method error

    rs.absolute(2);
    rs.updateInt(1,2);
    rs.updateString(2,"here");
    rs.updateRow();
    but here it shows an error message like
    PreResset.java:20: cannot find symbol
    symbol : method updateSting(int,java.lan
    location: interface java.sql.ResultSet
    rs.updateSting(2,"dev");
    please how can i update the data in database by using absolute method
    Edited by: Ram_mca04 on Jan 23, 2009 12:12 AM

    BalusC wrote:
    jschell wrote:
    BalusC wrote:
    Ram_mca04 wrote:
    PreResset.java:20: cannot find symbol
    symbol : method updateSting(int,java.lan
    location: interface java.sql.ResultSet
    rs.updateSting(2,"dev");This just means that the mentioned method doesn´t exist in the ResultSet class which you´re using.
    According to the [API documentation|http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html#updateString(int,%20java.lang.String)] this method was introduced in Java 1.2. Either you´re using Java 1.1 or older, or there is some huge flaw in your environment.
    Or an older driver.He encountered the problem during compilation (cannot find symbol), not during runtime (NoSuchMethodError).True.
    And something else I noticed when re-reading - look closely at the posted method name.

  • Comapring Records in ResultSet  ,Issue of Performance

    Hi,
    i got a Table on which I am calling select ,and getting the resultset as in which some of the rows will Have first column value as same ,but subsequent columns may have data or null Values.I want to club all the values for same First Column Value.I did it like that in java,but is it cab done in Oracle Procedures it self.
    Any analysis of this code and Database Loops ideas would be helpful.
    esultSetMetaData rsd = Rs2.getMetaData();
    int n = rsd.getColumnCount();
    Vector val = new Vector(n);
    Vector val2 = new Vector(n);
    System.out.println("No Of Columns--"+n);
    while(Rs2.next())
         if(Rs2.isFirst())
              for(int l=1;l<=n;l++)
              val.add(l-1,(Object)Rs2.getString(l));
         else
                   for(int j=1;j<=n;j++)
              val2.add(j-1,(Object)Rs2.getString(j));
                   if(val2.get(0).toString().equals(val.get(0).toString()))
                             System.out.println("same orderheaderid"+val2.get(0).toString());
                             i--;
                             for(int k=1;k<=n;k++)
                             if(val.get(k-1)==null)
                                  if(val2.get(k-1)!=null)
                                  val.set(k-1,val2.get(k-1));
                             val2.clear();
                             if(Rs2.isLast())
                                  for(int l=1;l<=n;l++)
                                       System.out.println(val.get(l-1));
                             else
                        else
                   {          System.out.println("different if"+val.get(0));
                             for(int f=1;f<=n;f++)
                                  System.out.println(f-1+"------"+val.get(f-1));
                        System.out.println("Count Value is--"+i);
                        val.clear();
                        val =(Vector)val2.clone();
                        if(Rs2.isLast())
                             for(int r=1;r<=n;r++)
                                  System.out.println(val2.get(r-1));
                        else
                             for(int s=1;s<n;s++)
                                  val.set(s-1,val2.get(s-1));
                        val2.clear();
                        val2 = (Vector)val.clone();
              }i++;
              //z++;
    Rs2.close();
    Thank u
    Vasu

    Double post:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=544516&tstart=0&trange=15
    http://forum.java.sun.com/thread.jsp?forum=48&thread=544517&tstart=0&trange=15
    Sounds like it breaks the rules for first normal form to me:
    http://databases.about.com/library/weekly/aa081901a.htm

  • How do I get the absolute best performance out of my MacBook Pro while playing Minecraft/Java Based Games?

    I pretty much want to know how to boost my laptop performance for the lowest price. Is there much to do after upgrading to 8 gigs of RAM and a Samsung SSD? Also is there anyway to upgrade a MacBook Pro early 2011 2.0 GHz i7 Graphics card?

    you run into the limits of XP and built in graphics.
    I would hope that you found in all these years how to install and get new moddified gpu drivers.
    XP is limited and is 32-bit where each app gets 2GB address space also.
    Windows 7 64-bit (or 8 even free for now to test out) otherwise wait to buy a new Mac.

  • Help unable to make a Resultset.getString(int)

    Hi,
    I'm a beginner in JAVA whose should create a statistical web site.
    When I use the Resulset.getString it's working well the first time, but after it throws me an SQLexception as No data found or [ORACLE] [ODBC] strange value <my int>. I'm using JDK 1.2 and JSWDK 1.0.
    Can someone help me, I understand nomore on this thing.
    I'll put a part of my code
    while(rs.next())
    System.out.println("On e ds while");
    n=rs.getString("Assigned_To_Individual_");
    System.out.println("val de n = " +n);
    System.out.println("val de nom = " +nom);
    if (nom==n)
    System.out.println("Ds 1 if " + nom);
    compteur++;
    wait();
    else
    System.out.println("Ds else " + nom);
    tab[indice]=compteur;
    System.out.println("ap tab ");
    indice++;
    compteur=0;
    System.out.println("Ds avt nom ");
    nom=n;
    System.out.println("Ds apr nom ");
    %>
    <TR>
    <%
    System.out.println("avt le for");
    for(int i=1 ; i < rsmd.getColumnCount()+1 ; i++)
    System.out.println("ds la for " +n);
    %>
    <TD><%= rs.getString(i) %></TD>// IT CRASH HERE WHY ????
    <%
    cpt++;
    }%>
    Thanks a lot
    STF
    </TR>
    <%
    %>

    for(int i=1 ; i < rsmd.getColumnCount()+1 ; i++)
    why r u doing rsmd.getColumnCount() +1
    u should be doing
    for( int i= 0; i<rsmd.getColumnCount(); i++)
    i guess you r getting an ArrayOut of bounds exception
    I think you are right. As an old C++ programmer myself I had to check out every array length type method to see if it has a base of 0 or base of 1 and it turns out that getColumnCount() is one of those base 1 array lengths. Thus creating that boundary error.

  • Very-large-scale searching in J2EE

    I'm looking to solve a very-large-scale searching problem. I am creating a site
    where users can search a table with five million records, filtering and sorting
    independantly on ten different columns. For example, the table might be five million
    customers, and the user might choose "S*" for the last name, and sort ascending
    on street name.
    I have read up on a number of patterns to solve this problem, but anticipate some
    performance issues. I'll explain below:
    1) "Page-by-Page Iterator" or "Value List Handler"
    In this pattern, it appears that all records that match the search criteria are
    retrieved from the database and cached on the application server. The client (JSP)
    can then access small pieces of the cached results at a time. Issues with this
    include:
    - If the customer record is 1KB, then wide search criteria (i.e. last name =
    S*) will cause 1 GB transfer from the database server to app server, and then
    1GB being stored on the app server, cached, waiting for the user (each user!)
    to ask for the next 10 or 100 records. This is inefficient use of network and
    memory resources.
    - 99% of the data transfered from the database server will not by used ... most
    users flip through a couple of pages and then choose a record or start a new search
    2) Requery the database each time and ask for a subset
    I haven't seen this formalized into a pattern yet, but the basic idea is this:
    If a clients asks for records 1-100 first (i.e. page 1), only fetch that many
    records from the db. If the user asks for the next page, requery the database
    and use the JDBC API's ResultSet.absolute(int row) to start at record 101. Issue:
    The query is re-performed, causing the Oracle server to do another costly "execute"
    (bad on 5M records with sorting).
    To solve this, I've beed trying to enhance the second strategy above by caching
    the ResultSet object in a stateful session bean. Unfortunately, this causes a
    "ResultSet already closed" SQLException, although I ensure that the Connection,
    PreparedStatement, and ResultSet are all stored in the EJB and not closed. I've
    seen this on newsgroups ... it appears that WebLogic is forcing the Connection
    closed. If this is how J2EE and pooled connections work, then that's fine ...
    there's nothing I can really do about it.
    Another idea is to use "explicit cursors" in Oracle. I haven't fully explored
    it yet, but it wouldn't be a great solution as it would be using Oracle-specific
    functionality (we are trying to be db-agnostic).
    More information:
    - BEA WebLogic Server 8.1
    - JDBC: Oracle's thin driver provided with WLS 8.1
    - Platform: Sun Solaris 5.8
    - Oracle 9i
    Any other ideas on how I can solve this issue?

    Michael McNeil wrote:
    I'm looking to solve a very-large-scale searching problem. I am creating a site
    where users can search a table with five million records, filtering and sorting
    independantly on ten different columns. For example, the table might be five million
    customers, and the user might choose "S*" for the last name, and sort ascending
    on street name.
    I have read up on a number of patterns to solve this problem, but anticipate some
    performance issues. I'll explain below:
    1) "Page-by-Page Iterator" or "Value List Handler"
    In this pattern, it appears that all records that match the search criteria are
    retrieved from the database and cached on the application server. The client (JSP)
    can then access small pieces of the cached results at a time. Issues with this
    include:
    - If the customer record is 1KB, then wide search criteria (i.e. last name =
    S*) will cause 1 GB transfer from the database server to app server, and then
    1GB being stored on the app server, cached, waiting for the user (each user!)
    to ask for the next 10 or 100 records. This is inefficient use of network and
    memory resources.
    - 99% of the data transfered from the database server will not by used ... most
    users flip through a couple of pages and then choose a record or start a new search
    2) Requery the database each time and ask for a subset
    I haven't seen this formalized into a pattern yet, but the basic idea is this:
    If a clients asks for records 1-100 first (i.e. page 1), only fetch that many
    records from the db. If the user asks for the next page, requery the database
    and use the JDBC API's ResultSet.absolute(int row) to start at record 101. Issue:
    The query is re-performed, causing the Oracle server to do another costly "execute"
    (bad on 5M records with sorting).
    To solve this, I've beed trying to enhance the second strategy above by caching
    the ResultSet object in a stateful session bean. Unfortunately, this causes a
    "ResultSet already closed" SQLException, although I ensure that the Connection,
    PreparedStatement, and ResultSet are all stored in the EJB and not closed. I've
    seen this on newsgroups ... it appears that WebLogic is forcing the Connection
    closed. If this is how J2EE and pooled connections work, then that's fine ...
    there's nothing I can really do about it.
    Another idea is to use "explicit cursors" in Oracle. I haven't fully explored
    it yet, but it wouldn't be a great solution as it would be using Oracle-specific
    functionality (we are trying to be db-agnostic).
    More information:
    - BEA WebLogic Server 8.1
    - JDBC: Oracle's thin driver provided with WLS 8.1
    - Platform: Sun Solaris 5.8
    - Oracle 9i
    Any other ideas on how I can solve this issue? Hi. Fancy SQL to the rescue! If the table has a unique key, you can simply send a
    query per page, with iterative SQL that selects the next N rows beyond what was
    selected last time. Eg:
    Let variable X be the highest key value you've seen so far. Initially it would
    be the lowest possible value.
    select * from mytable M
    where ... -- application-specific qualifications...
    and M.key >= X
    and (100 <= select count(*) from mytable MM where MM.key > X and MM.key < M.key and ...)
    In English, this says, select all the qualifying rows higher than what I last saw, but
    only those that have fewer than 100 qualifying rows between the last I saw and them (ie:
    the next 100).
    When processing this query, remember the highest key value you see, and use it for the
    next query.
    Joe

  • Mysterious closing ResultSets

    I'm getting desperate for a solution to this problem (as is the rest of the development team!).
    Basically we've been trying to create a system that automatically assigns values (frequencies) to objects (nodes) based on a rule set. Each node contains a varying number of sub-objects (radios) and each radio needs one frequency. The database has been set up and has test data for our Solution class to go through. However, we've run into an odd problem where our ResultSets are suddenly closing.
    The classes work like this:
    Database Broker (handles connection to DB, as well as executeQuery and executeUpdate statements.)
    Entry Broker (Holds all SQL statements for data retrieval in various methods. Each method contains an SQL statement to access data, and code to format that data into something useable by the main class.
    Solution/Main class (Contains methods to use the data from the Entry Broker to test valid solutions. Certain rules apply to assigning frequencies to radios and this class ensures that the data applies to these rules before it writes the data back to the DB (via the EntryBroker).
    The problem we continually run into is that whilst the ResultSets work fine in the Entry Broker, they are closed when they return to the Main class.
    Here's the catch: It seems in most cases that only the FIRST ResultSet returned in each method is closed, the remaining ResultSets work fine. We worked around this problem by creating a 'dummy' ResultSet, which obtained data from the database which was never used (the project name). We put this in its own try catch bracket so it would not interrupt the project.
    It worked fine for a few classes, but for others (notably the following one) it was ineffective. We've searched and searched but we cannot find anyone with a similar complaint (except a few people who have commented about ODBC version problems). Our ODBC version is 3.520.7713.0
    Here's an example method from the Solution class (The entire class is over 1000 lines):
    // Method to test Harmonic resonance for nodes within 10m
    private boolean resonanceGlobal (boolean tstResonanceG, double txFreq, double rxFreq, int distance)     {
    System.out.println("Beginning global harmonic resonance check");
    try {
    // Getting Nodes
    rsNode2 = eBroker.getNodes(projectNo);
    // node loop
    while (rsNode2.next())     {
    System.out.println("602 Test Marker GHarm 1");
    // get next node, store in nodeTemp
    nodeTemp = rsNode2.getInt(1);
    // System out to show which nodes will pass if statement
    System.out.println(node + " compare to " + nodeTemp);
    // avoid testing the same node against itself
    if (nodeTemp != node)     {
    // distance check (only neccesary within 10m)
    System.out.println("Test Marker Before Distance check");
    distance = getDistance(node, nodeTemp, distance);
    System.out.println("Test Marker After Distance check");
    // distance check if statement
    if (distance <= 10)     {
    System.out.println("618 Test Marker GHarm 2");
    // get the radios of the node, foreign node
    rsRadiosTemp = eBroker.getRadios(node);
    rsDummy = eBroker.getDummy(projectNo);
    rsRadios2 = eBroker.getRadios(nodeTemp);
    // This dummy ResultSet normally fails so that
    // the other ResultSets perform normally
    try {
    rsDummy.next();
    }     // end try
    catch (java.sql.SQLException dummyException)     {
    System.out.println("dummyException " + dummyException);
    }     // end catch
    // radio loop
    while (rsRadiosTemp.next())     {     // error occurs here
    System.out.println("627 Test Marker GHarm 3");
    // loop for foreign node radios
    while (rsRadios2.next())     {
    System.out.println("631 Test Marker GHarm 4");
    // get next radio
    radioTemp = rsRadios2.getInt(1);
    // get the TX and RX of the radio
    genericTX = getTX(radioTemp);
    radioTempCon = getConnection(radioTemp);
    genericRX = getTX(radioTempCon);
    // calculate bounds for harmonics test
    txLo = ((txFreq * 2) - genericTX) - 4;     // 4Mhz below TX harmonics check
    txHi = ((txFreq * 2) - genericTX) + 4;     // 4Mhz above TX harmonics check
    rxHi = ((rxFreq * 2) - genericRX) + 4;     // 4Mhz above RX harmonics check
    rxLo = ((rxFreq * 2) - genericRX) - 4;     // 4Mhz below RX harmonics check
    // checks TX and RX of foreign radio against TX, RX of current radio for separation
    if ((txLo > genericTX && txHi < genericTX) || (rxLo > genericRX && rxHi < genericRX))     {
    tstResonanceG = false;     
    break;
    } //end if
    else {
    tstResonanceG = true;
    }     // end else
    } //end foreign radio loop
    // breaking out of loops for return
    if (tstResonanceG == false)
    break;
    }     // end radio loop
    rsRadios2.close();
    rsRadiosTemp.close();
    }     // end sameradio check
    }     // end distance check
    }// end node loop
    rsNode2.close();
    }     // end try
    // Catch statement to stop from crashing in the
    // event of an error during SQL statements.
    catch (java.sql.SQLException resonanceGlobalException) {
    // Prints out the error message produced
    System.out.println(resonanceGlobalException);
    }     // end catch
    // returns result
    return tstResonanceG;
    } //end checkHarmonicResonanceGlobal()
    My apologies if it is a little hard to read, but the indenting is accurate. The Entry Broker methods which this method uses are here:
    public ResultSet getNodes (int projectNo) {
    // creating SQL statement
    sqlStatement = "SELECT nodeNo from tblNode WHERE projectNo = " + projectNo;
    System.out.println(sqlStatement);
    // executing SQL statement
    rsNodes = db.runQuery(sqlStatement);
    // returns ResultSet
    return rsNodes;
    }     // end getNodes
    // Method to get the distance between any two nodes
    public int getDistance (int projectNo, int node, int tempNode)     {
    ResultSet rsX1;                         // Used for obtaining the X-coord of node 1
    ResultSet rsX2;                         // Used for obtaining the X-coord of node 2
    ResultSet rsY1;                         // Used for obtaining the Y-coord of node 1
    ResultSet rsY2;                         // Used for obtaining the Y-coord of node 2
    double distance = 0;                    // Used in Global checks
    int dist = 0;                              // Used in Global checks
    int x1 = 0;                                   // Used in calculating distance
    int x2 = 0;                                   // Used in calculating distance
    int y1 = 0;                                   // Used in calculating distance
    int y2 = 0;                                   // Used in calculating distance
    int xDist = 0;                              // Used in calculating distance
    int yDist = 0;                              // Used in calculating distance
    int distint = 0;                         // Used to store converted values
    try {
    // get the X and Y co-ordinates of both nodes
    sqlStatement = "SELECT xCoord FROM tblNode WHERE nodeNo = " + node + " AND projectNo = " + projectNo;
    rsX1 = db.runQuery(sqlStatement);
    rsX1.next();
    x1 = rsX1.getInt(1);
    sqlStatement = "SELECT yCoord FROM tblNode WHERE nodeNo = " + node + " AND projectNo = " + projectNo;
    rsY1 = db.runQuery(sqlStatement);
    rsY1.next();
    y1 = rsY1.getInt(1);
    sqlStatement = "SELECT xCoord FROM tblNode WHERE nodeNo = " + tempNode + " AND projectNo = " + projectNo;
    rsX2 = db.runQuery(sqlStatement);
    rsX2.next();
    x2 = rsX2.getInt(1);
    sqlStatement = "SELECT yCoord FROM tblNode WHERE nodeNo = " + tempNode + " AND projectNo = " + projectNo;
    rsY2 = db.runQuery(sqlStatement);
    rsY2.next();
    y2 = rsY2.getInt(1);
    }     // end try
    catch (java.sql.SQLException getDistanceException) {
    System.out.println(getDistanceException);
    // calculating distance
    yDist = y2 - y1;
    xDist = x2 - x1;
    // perform pythagoras theorem for distance
    dist = (xDist * xDist) + (yDist * yDist);
    distance = java.lang.Math.sqrt(dist);
    Double roundFreqTemp = new Double(freqTemp);
    distint = roundFreqTemp.intValue() ;
    return distint;
    } // end get distance method
    // Method to get all the radios in a node
    public ResultSet getRadios(int node)     {
    ResultSet rsRadios;          // Used for obtaining radios in a node
    // creating sql Statement
    sqlStatement = "SELECT * FROM tblRadio WHERE nodeNo =" + node;
    System.out.println(sqlStatement);
    // executing sql Statement
    rsRadios = db.runQuery(sqlStatement);
    System.out.println("EB Test Marker 1: Line 261");
    // returning radio no
    return rsRadios;
    }//end getRadio
    public double getTX(int radioTemp){
    double txTemp = 0;     // Used for storing TX of a radio
    int freqNoTemp = 0; // Used for storing the frequency ID
    rsDummy = getDummy(projectNo);
    // creating SQL statement
    sqlStatement ="Select frequencyNo from tblRadio where radioNo = " + radioTemp;
    System.out.println(sqlStatement);
    // executing SQL statement
    rsTX = db.runQuery(sqlStatement);
    try {
    System.out.println("Test Marker EB1: 317");
    try {
    rsDummy.next();
    }     // end try
    catch     (java.sql.SQLException dummyException)     {
    System.out.println("dummyException" + dummyException);
    }     // end catch
    System.out.println("Test MarkerEB2: 330");
    // moving to first position in rs
    rsTX.next();
    System.out.println("Test MarkerEB3: 334");
    // obtaining data from rs
    freqNoTemp = rsTX.getInt(1);
    System.out.println("Test MarkerEB4: 337");
    rsTX.close();
    }     // end try
    catch (java.sql.SQLException rsTXException)     {
    System.out.println("rsTXExeption: " + rsTXException);
    }     // emd catch
    System.out.println("Frequency No is: " + freqNoTemp);
    rsDummy = getDummy(projectNo);
    sqlStatement = "Select frequency from tblFreq where frequencyNo = " + freqNoTemp;
    System.out.println(sqlStatement);
    rsRX = db.runQuery(sqlStatement);
    try {
    try {
    System.out.println("Test MarkerEB6: 361");
    rsDummy.next();
    }     // end try
    catch     (java.sql.SQLException dummyException)     {
    System.out.println("dummyException" + dummyException);
    }     // end catch
    System.out.println("Test MarkerEB5: 373");
    rsRX.next();
    System.out.println("Test MarkerEB7: 376");
    txTemp = rsRX.getDouble(1);
    System.out.println("Test MarkerEB8: 379");
    rsRX.close();
    }     // end try
    catch (java.sql.SQLException rxException) {
    System.out.println("rxException " + rxException);
    } // end catch
         System.out.println("393 Before return");
    return txTemp;
    }     //end getTX
    public int getConnection(int radio) {
    int nodeCon = 0;                    // Used to return the connected node no
    ResultSet rsConnection;          // Used for obtaining the foreign radio
    // creating SQL statement
    sqlStatement = "SELECT radioNo FROM tblRadio where recRadio = " + radio;
    System.out.println(sqlStatement);
    // executing SQL statement
    rsConnection = db.runQuery(sqlStatement);
    try {
    // moving to first position in rs
    rsConnection.next();
    // obtaining data from rs
    nodeCon = rsConnection.getInt(1);
    }     // end try
    catch (java.sql.SQLException getConnectionException) {
    System.out.println("getConnectionException : " + getConnectionException);
    }     // end catch
    // returns node no.
    return nodeCon;
    And finally, the dummy rs:
    // Dummy method to fix resultSet closed error
    public ResultSet getDummy (int projectNo) {
    sqlStatement = "Select projectName from tblProject where projectNo = " + projectNo;
    System.out.println(sqlStatement);
    rsDummy = db.runQuery(sqlStatement);
    return rsDummy;
    Here is some sample output that we have:
    ----jGRASP exec: java MainGui
    slider value constructor: 50
    116: if(singleton==null) {
    120: singleton=new Resolvotron
    Connection to D/Base establised
    Select projectName from tblProject where projectNo = 3
    Init OK. Beginning solve process
    main OK: beginning frequency assign process
    SELECT nodeNo from tblNode WHERE projectNo = 3
    267: Node number = 2
    SELECT * FROM tblRadio WHERE nodeNo =2
    EB Test Marker 1: Line 261
    Test Marker 1: Line 289
    298: Radio number = 4
    Test Marker 5: Line 308
    Test Marker 3: Line 313
    SELECT frequency from tblFreq WHERE projectNo = 3
    125.5
    Beginning test process
    Test Marker 4: Line 386
    Beginning check 257072
    Test Marker 6: Line 774
    70 Mhz Margin = false
    Beginning local 10Mhz separation check
    SELECT * FROM tblRadio WHERE nodeNo =2
    EB Test Marker 1: Line 261
    Getting TX of radio: 4
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 4
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB5: 373
    Test MarkerEB7: 376
    Test MarkerEB8: 379
    393 Before return
    432: getting connection
    SELECT radioNo FROM tblRadio where recRadio = 4
    438: getting TX of radio: 6
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 6
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB5: 373
    Test MarkerEB7: 376
    Test MarkerEB8: 379
    393 Before return
    java.sql.SQLException: ResultSet is closed
    10 Mhz Local = true
    Beginning 10 Mhz separation check
    SELECT nodeNo from tblNode WHERE projectNo = 3
    Node number is 2
    10 Mhz Global = false
    Beginning local harmonic resonance check
    SELECT * FROM tblRadio WHERE nodeNo =2
    EB Test Marker 1: Line 261
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 4
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB5: 373
    Test MarkerEB7: 376
    Test MarkerEB8: 379
    393 Before return
    SELECT radioNo FROM tblRadio where recRadio = 4
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 6
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    I'll leave it at that, since the program goes into an endless loop. The dummy Exceptions are our dummy resultsets crashing so the rest can survive. The other stuff is from different methods. You should be able to locate the logic of the program by following the System.outs
    Test Markers with EB refer to the Entry Broker.
    Any help would be appreciated since we cannot find any other way of running this class successfully.
    Steve

    Ok problem solved...
    Basically I was calling one ResultSet after another. Thanks to the Database Broker's structure, this was killing the first ResultSet. I fixed up the loops so that ResultSets were only ever called just before they were needed, and it fixed the problem. The only other errors were simple logic faults which I drummed out in short order. Thanks for the help everyone!

  • Using all types of resultset Objects i need a single program

    i think all of u know that there are 8 types of resultset objects are there in jdbc technology i.e
    # next() - moves the cursor forward one row. Returns true if the cursor is now positioned on a row and false if the cursor is positioned after the last row.
    # previous() - moves the cursor backwards one row. Returns true if the cursor is now positioned on a row and false if the cursor is positioned before the first row.
    # first() - moves the cursor to the first row in the ResultSet object. Returns true if the cursor is now positioned on the first row and false if the ResultSet object
    does not contain any rows.
    # last() - moves the cursor to the last row in the ResultSet object. Returns true if the cursor is now positioned on the last row and false if the ResultSet object
    does not contain any rows.
    # beforeFirst() - positions the cursor at the start of the ResultSet object, before the first row. If the ResultSet object does not contain any rows, this method has
    no effect.
    # afterLast() - positions the cursor at the end of the ResultSet object, after the last row. If the ResultSet object does not contain any rows, this method has no effect.
    # relative(int rows) - moves the cursor relative to its current position.
    # absolute(int n) - positions the cursor on the n-th row of the ResultSet object.
    Using all these result set methods i need a sample program all these methods must be used in a single program itself

    BalajiEnntech123 wrote:
    i think all of u know that there are 8 types of resultset objects are there in jdbc technology i.e I don't know who "u" are but they're wrong if they think there are "8 types of resultset objects are there in jdbc technology".
    They'd be especially wrong to think that the methods you mention are "types of resultset objects".

  • Problem with GenericCatalogDAO  JDBC Resultset using parameters not working

    Hello
    I have a problem with Petstore GenericCatalogDAO. java. The problem is the behaviour of the resultset object when retrieving data from the database.Below are two synareos one that
    works (when) hard coded and one that does not work when parameter values passed into the the result set.
    1. The code the WORKS.
    statement = connection.prepareStatement("select a.productid , name, descn from product a, product_details b
    where a.productid = b.productid and locale= 'en_US' and a.catid = 'FISH' order by name"
    ,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    resultSet = statement.executeQuery();
    resultSet.absolute(1);
    String s = resultSet.getString(1);
    The code that gives me a 'exhausted resultset' error which I think means no results
    String[] parameterValues = new String[] { locale.toString(), categoryID };(For example parameters are 'en_US' and 'FISH')
    statement = connection.prepareStatement("select a.productid , name, descn from product a, product_details b
    where a.productid = b.productid and locale=? and a.catid =? order by name"
    ,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    for (int i = 0; i < parameterValues.length; i++) {
    statement.setString(i + 1, parameterValues[i]);
    resultSet = statement.executeQuery();
    resultSet.absolute(1);
    String s = resultSet.getString(1);
    There is obviously a problem using these named parametevalues with these preparedstatement resultset, Does anybody know anything about this and a fix for it????
    Cheers. Roger

    Which version of PetStore are you using?
    -Larry

  • JDBC Resultset Problem with ORACLE 10.1.0.2

    Hello
    I have a problem with Petstore GenericCatalogDAO. java. The problem is the behaviour of the resultset object when retrieving data from the database.Below are two synareos one that
    works (when) hard coded and one that does not work when parameter values passed into the the result set.
    1. The code the WORKS.
    statement = connection.prepareStatement("select name from employee where a.name ='SMITH' order by name"
    ,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    resultSet = statement.executeQuery();
    resultSet.absolute(1);
    String s = resultSet.getString(1);
    The code that gives me a 'exhausted resultset' error which I think means no results
    String[] parameterValues = new String[] { "SMITH" };
    statement = connection.prepareStatement("select name from employee where a.name =? order by name ",
    ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
    for (int i = 0; i < parameterValues.length; i++) {
    statement.setString(i + 1, parameterValues);
    resultSet = statement.executeQuery();
    resultSet.absolute(1);
    String s = resultSet.getString(1);
    There is obviously a problem using these named parametevalues with these preparedstatement resultset, Does anybody know anything about this and a fix for it????
    Cheers. Roger

    Roger,
    It's probably a mistake you made when posting your code, but your query string is incorrect it should be either:
    select name from employee where name = 'SMITH' order by nameor
    select a.name from employee a where a.name = 'SMITH' order by a.nameIn other words you have prefixed a column with a table alias but have not indicated a table alias in the query.
    Also, shouldn't your code be:
    for (int i = 0; i < parameterValues.length; i++) {
        statement.setString(i + 1, parameterValues[ i ]);
    }Or was the "[ i ]" part giving you trouble? (Since "[ i ]" -- without the spaces -- is treated as a text-formatting tag.)
    While I didn't try your specific query, I have no problem using "PreparedStatment"s with parameters.
    What is your environment? Mine is:
    Oracle 10g (10.1.0.4) database on Linux (Red Hat)
    JDK 1.4.2
    ojdbc14.jar JDBC driver (latest version)
    Good Luck,
    Avi.

Maybe you are looking for

  • Convert ps to pdf  - watched folders process one at a time ?

    does the destiller server process the watched folders one at a time or it can process several depending on the license? i have the "normal" distiller and i have this problem, if a huge file is being converted, the other files from watched folders are

  • Error Starting Weblogic Console

    I am getting the following error while starting weblogic 5.1 console under solaris. Please help. Exception in thread "main" java.lang.UnsatisfiedLinkError: no awt in java.library.path at java.lang.Throwable.fillInStackTrace(Native Method) at java.lan

  • Slow Reader printing

    All of a sudden printing a PDF has become excruciatingly slow. It has always been a little slow, but now it is much worse. Adobe Reader 8 - Mac G5 OS 10.4.11

  • Create Contact Person With Reference to Supplier - Massive

    Hi all, We are running SRM 7.01. We create contact persons manually with button "Create Contact Person With Reference". How can we do this in a massive way for all our vendors? Thanks Ezequiel

  • Camera lock screen iPhone 5 not working properly after upgrade to iOS 8

    After I installed iOS 8 on the iPhones 5 of my and my wife's the camera on the lock screen isn't working properly anymore. When I swipe up, the camera starts but the screen turns black within less then a second. On the iPad 2 and the iPad Air (both u