Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6456659

CachedRowSetImpl fails with postgresql driver and release b92 and b93

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      x86
    • OS:
      linux
    • Verification:
      Verified

      Backports

        Description

        FULL PRODUCT VERSION :
        Java(TM) SE Runtime Environment (build 1.6.0-rc-b93)
        Java HotSpot(TM) Client VM (build 1.6.0-rc-b93, mixed mode, sharing

        ADDITIONAL OS VERSION INFORMATION :
        Linux roadwarrior 2.6.16-1.2115_FC4 #1 Mon Jun 5 14:45:53 EDT 2006 i686 i686 i386 GNU/Linux


        EXTRA RELEVANT SYSTEM CONFIGURATION :
        (PostgreSQL) 8.2devel


        A DESCRIPTION OF THE PROBLEM :
        Some code that used to work OK with mustang b82 fails after changing to b92, and fails too with b93. It is simply a CachedRowSetImpl with postgresql driver.
        After changing to b92, postgresql driver starts complaining that CachedRowSetImpl's internal ResultSet is TYPE_FORWARD_ONLY and needs a TYPE_SCROLL_SENSITIVE or TYPE_SCROLL_INSENSITIVE one. In fact, I verified that CachedRowSetImpl's getType() returns TYPE_SCROLL_INSENSITIVE but postgresql driver still see it as one of a different type.
        Just changing back to b82, without any other change (same code, same postgresql driver, same Netbeans project), solves the problem and my code start to working OK again.

        The stack trace:

        org.postgresql.util.PSQLException: Operation requires a scrollable ResultSet, but this ResultSet is FORWARD_ONLY.
                at org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkScrollable(AbstractJdbc2ResultSet.java:189)
                at org.postgresql.jdbc2.AbstractJdbc2ResultSet.absolute(AbstractJdbc2ResultSet.java:195)
                at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:7183)
                at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:602)
                at com.sun.rowset.internal.CachedRowSetReader.readData(CachedRowSetReader.java:180)
                at com.sun.rowset.CachedRowSetImpl.execute(CachedRowSetImpl.java:685)
                at com.sun.rowset.CachedRowSetImpl.execute(CachedRowSetImpl.java:1347)
                at com.adminsa.beans.clickableList.ClickableList.populate(ClickableList.java:164)
                at com.adminsa.beans.clickableList.ClickableList.setSqlQuery(ClickableList.java:238)
                at com.adminsa.beans.clickableList.ClickableList.setTable(ClickableList.java:205)
                at com.adminsa.accounting.gui.SumasYSaldosPanel.initComponents(SumasYSaldosPanel.java:202)
                at com.adminsa.accounting.gui.SumasYSaldosPanel.<init>(SumasYSaldosPanel.java:29)
                at com.adminsa.accounting.gui.SumasYSaldosPanel$2.run(SumasYSaldosPanel.java:286)
                at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
                at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
                at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
                at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
                at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
                at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
                at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

        After looking into mustang code I saw that there are several differences in CachedRowSetImpl between b82 abd b92 but version number and date is the same . It is that correct ?.

        The header for both versions (b82 and b93) is the same :
        /*
         * @(#)CachedRowSetImpl.java 1.18 06/03/24
         *
         * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
         * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
         */

        I verified that for JdbcRowSetImpl too.

        The attached code reproduces this error. A postgresql server is required.

        REGRESSION. Last worked in version mustang

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached program. Or call CachecRowSetImpl populate() method with a postgresql driver.

        ACTUAL -
        A ResultSet READONLY false
        A ResultSet WRITEONLY true
        A ResultSet Type and Con 1003 1007
        org.postgresql.util.PSQLException: Operation requires a scrollable ResultSet, but this ResultSet is FORWARD_ONLY.
                at org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkScrollable(AbstractJdbc2ResultSet.java:189)
                at org.postgresql.jdbc2.AbstractJdbc2ResultSet.absolute(AbstractJdbc2ResultSet.java:195)
                at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:7183)
                at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:602)
                at CachedRowSetImplTest.main(CachedRowSetImplTest.java:44)


        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        org.postgresql.util.PSQLException: Operation requires a scrollable ResultSet, but this ResultSet is FORWARD_ONLY.
                at org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkScrollable(AbstractJdbc2ResultSet.java:189)
                at org.postgresql.jdbc2.AbstractJdbc2ResultSet.absolute(AbstractJdbc2ResultSet.java:195)
                at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:7183)
                at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:602)
                at CachedRowSetImplTest.main(CachedRowSetImplTest.java:44)


        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.sql.*;
        import javax.sql.*;
        import com.sun.rowset.*;
        import javax.sql.rowset.*;
        import javax.sql.rowset.spi.*;

        public class CachedRowSetImplTest {
           public static void main(String args[])
           {
             Connection con = null;

             try
             {
               String driver, url;

               driver ="org.postgresql.Driver";
               url = "jdbc:postgresql://localhost/test";

               Class.forName(driver).newInstance();
               Statement s;

               con = DriverManager.getConnection(url, "dags", "");

               s = con.createStatement();
               s.executeUpdate("DROP TABLE test;");
               s.executeUpdate("CREATE TABLE test (age integer, name text)");
               s.executeUpdate ("insert into test values(2, null)");
               s.close();


               RowSetMetaDataImpl rsmd1;
               ResultSetMetaData resmd1;

               CachedRowSetImpl crs1 = new CachedRowSetImpl();

               s = con.createStatement();

               ResultSet result = s.executeQuery ("Select * from test");
               resmd1 = result.getMetaData();
               System.out.println("A ResultSet READONLY " + resmd1.isReadOnly(1));
               System.out.println("A ResultSet WRITEONLY " + resmd1.isWritable(1));
               System.out.println("A ResultSet Type and Con " + result.getType() + " " + result.getConcurrency());

               crs1.populate(result);
               rsmd1 = (RowSetMetaDataImpl)crs1.getMetaData();
               System.out.println("B RowSet READONLY " + rsmd1.isReadOnly(1));
               System.out.println("B RowSet WRITEONLY " + rsmd1.isWritable(1));
               System.out.println("B CacheRowIMP Type and Con " + crs1.getType() + " " + crs1.getConcurrency());


             }
             catch (Exception e)
            {
              e.printStackTrace();
            }
           }
        }
        ~

        ---------- END SOURCE ----------

        Release Regression From : mustang
        The above release value was the last known release where this
        bug was not reproducible. Since then there has been a regression.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  lancea Lance Andersen
                  Reporter:
                  ndcosta Nelson Dcosta (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: