JDK-6983452 : No way to plug SyncProvider for JoinRowSet implementation
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.sql
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-09-09
  • Updated: 2012-03-22
  • Resolved: 2010-10-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b114Fixed
Related Reports
Relates :  
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.

Comments
EVALUATION This issue has been there since the 1st release of the RowSets and this feature is not currently used. The original issue 6322649 was addressed in 2006 and it appears that JoinRowSets was not tested at that time. I do not see this as a showstopper.
09-09-2010