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

No way to plug SyncProvider for JoinRowSet implementation

    Details

    • Subcomponent:
    • Resolved In Build:
      b114
    • CPU:
      generic
    • OS:
      generic

      Description

      The sample program below shows that it's not possible to plug a SyncProvider instance for a JoinRowSet rowset implementation.

      ---------------- Test.java -----------------------
      import java.io.Serializable;
      import java.sql.Types;
      import javax.sql.rowset.spi.*;
      import javax.sql.rowset.*;
      import javax.sql.*;

      public class Test extends SyncProvider implements RowSetReader,
              RowSetWriter, Cloneable, Serializable, RowSetListener {

          static {
              try {
                  SyncFactory.registerProvider(Test.class.getName());
              } catch (SyncFactoryException ex) {
                  throw new RuntimeException(ex);
              }
          }
          protected int datasource_lock = SyncProvider.DATASOURCE_NO_LOCK;

          public void setDataSourceLock(int datasource_lock)
                  throws SyncProviderException {
              this.datasource_lock = datasource_lock;
          }

          public int supportsUpdatableView() {
              return SyncProvider.UPDATABLE_VIEW_SYNC;
          }

          public String getVersion() {
              return "1.0";
          }

          public String getVendor() {
              return "Spb JCK Team";
          }

          public RowSetWriter getRowSetWriter() {
              return this;
          }

          public RowSetReader getRowSetReader() {
              return this;
          }

          public String getProviderID() {
              return getClass().getName();
          }

          public int getProviderGrade() {
              return SyncProvider.GRADE_NONE;
          }

          public int getDataSourceLock() throws SyncProviderException {
              return datasource_lock;
          }

          public boolean writeData(RowSetInternal caller) throws
                  java.sql.SQLException {
              System.out.println("writeData");
              return true;
          }

          public void readData(RowSetInternal caller) throws java.sql.SQLException {
              System.out.println("readData");
          }

          public void rowSetChanged(RowSetEvent event) {
              System.out.println("rowSetChanged");
          }

          public void rowChanged(RowSetEvent event) {
              System.out.println("rowChanged");
          }

          public void cursorMoved(RowSetEvent event) {
              System.out.println("cursorMoved");
          }

          @Override
          public Object clone() throws CloneNotSupportedException {
              return super.clone();
          }

          public static void main(String[] argv) throws Exception {
              //final CachedRowSet crs = new com.sun.rowset.CachedRowSetImpl();
              final JoinRowSet crs = new com.sun.rowset.JoinRowSetImpl();

              crs.setSyncProvider(Test.class.getName());
              RowSetMetaDataImpl rsmdi = new RowSetMetaDataImpl();
              rsmdi.setColumnCount(1);
              rsmdi.setColumnName(1, "_char_");
              rsmdi.setColumnType(1, Types.CHAR);
              crs.setMetaData(rsmdi);
              crs.moveToInsertRow();
              crs.updateString(1, "Char value");
              crs.beforeFirst();
              System.out.println("READY");
              crs.execute();
              System.out.println("DONE");
          }

      }

      -----------------------------------------------------


      The program fails with the exception:
      <ag153348@spb-piker> /set/java/re/jdk/7/latest/binaries/linux-i586/bin/java -showversion -cp /net/spb-piker/export/users/ag153348/trash/JavaApplication5/build/classes Test
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b107)
      Java HotSpot(TM) Server VM (build 19.0-b05, mixed mode)

      READY
      Exception in thread "main" java.sql.SQLException: Internal Error in RowSetReader: no connection or command
      at com.sun.rowset.internal.CachedRowSetReader.readData(CachedRowSetReader.java:161)
      at com.sun.rowset.CachedRowSetImpl.execute(CachedRowSetImpl.java:800)
      at com.sun.rowset.CachedRowSetImpl.execute(CachedRowSetImpl.java:1432)
      at com.sun.rowset.JoinRowSetImpl.execute(JoinRowSetImpl.java:4030)
      at Test.main(Test.java:97)


      Changing the RowSet implementation type to other than JoinRowSet will make the code work. That became possible after the fix of CR 6322649.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                lancea Lance Andersen
                Reporter:
                agavrilosunw Alexey Gavrilov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: