1

I notice that I get same result if I use

    RowSetFactory rowSetFactory = RowSetProvider.newFactory();

and

    rowSetFactory = new RowSetFactoryImpl();

newFactory method implementation:

public static RowSetFactory newFactory()
            throws SQLException {
        // Use the system property first
        RowSetFactory factory = null;
        String factoryClassName = null;
        try {
            trace("Checking for Rowset System Property...");
            factoryClassName = getSystemProperty(ROWSET_FACTORY_NAME);
            if (factoryClassName != null) {
                trace("Found system property, value=" + factoryClassName);
                factory = (RowSetFactory) getFactoryClass(factoryClassName, null, true).newInstance();
            }
        } catch (ClassNotFoundException e) {
            throw new SQLException(
                    "RowSetFactory: " + factoryClassName + " not found", e);
        } catch (Exception e) {
            throw new SQLException(
                    "RowSetFactory: " + factoryClassName + " could not be instantiated: " + e,
                    e);
        }

Here we see that this method returns RowSetFactory which set in system.property.

What the reason to change this system property?

Who does set this property by default?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • You only get the same result if the system property hasn't been set explicitly... BTW: Your question is answered in the API doc: there can be alternative implementations, I fail to see why you need to ask this question. – Mark Rotteveel Aug 31 '14 at 14:27
  • Ok. I want to know situations when I should to use alternative implementation. and what can be different in alternative implementation? – gstackoverflow Aug 31 '14 at 20:45
  • 1
    The primary reason would be if that other implementation provides better support or fixes bugs; think of database implementation specific tricks to simply loading, refreshing or storing the data in the rowset. However, I don't actually know if there are any alternative implementations available. – Mark Rotteveel Sep 01 '14 at 07:21

1 Answers1

0

The com.sun.rowset.RowSetFactoryImpl class (see source code) is but one of possibly several concrete implementations of the RowSetFactory interface.

RowSetProvider & RowSetFactory make it easy to find default implementations as well as give you the flexibility to customize for particular implementations.

You can see this in the Javadoc of RowSetProvider.

  • Default:
    RowSetProvider.newFactory()
  • Custom:
    RowSetProvider.newFactory("com.sun.rowset.RowSetFactoryImpl", null)
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154