Example usage for javax.sql.rowset.spi SyncFactory getInstance

List of usage examples for javax.sql.rowset.spi SyncFactory getInstance

Introduction

In this page you can find the example usage for javax.sql.rowset.spi SyncFactory getInstance.

Prototype

public static SyncProvider getInstance(String providerID) throws SyncFactoryException 

Source Link

Document

Returns the SyncProvider instance identified by providerID.

Usage

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Constructs a new default <code>CachedRowSetImpl</code> object with
 * the capacity to hold 100 rows. This new object has no metadata
 * and has the following default values:
 * <pre>/*from ww w.j  a  v  a  2  s  . c om*/
 *     onInsertRow = false
 *     insertRow = null
 *     cursorPos = 0
 *     numRows = 0
 *     showDeleted = false
 *     queryTimeout = 0
 *     maxRows = 0
 *     maxFieldSize = 0
 *     rowSetType = ResultSet.TYPE_SCROLL_INSENSITIVE
 *     concurrency = ResultSet.CONCUR_UPDATABLE
 *     readOnly = false
 *     isolation = Connection.TRANSACTION_READ_COMMITTED
 *     escapeProcessing = true
 *     onInsertRow = false
 *     insertRow = null
 *     cursorPos = 0
 *     absolutePos = 0
 *     numRows = 0
 * </pre>
 * A <code>CachedRowSetImpl</code> object is configured to use the default
 * <code>RIOptimisticProvider</code> implementation to provide connectivity
 * and synchronization capabilities to the set data source.
 * <P>
 * @throws SQLException if an error occurs
 */
public BFTRowSet() throws SQLException {

    try {
        resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    // set the Reader, this maybe overridden latter
    provider = (SyncProvider) SyncFactory.getInstance(DEFAULT_SYNC_PROVIDER);

    if (!(provider instanceof RIOptimisticProvider)) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidp").toString());
    }

    rowSetReader = (CachedRowSetReader) provider.getRowSetReader();
    rowSetWriter = (CachedRowSetWriter) provider.getRowSetWriter();

    // allocate the parameters collection
    initParams();

    initContainer();

    // set up some default values
    initProperties();

    // insert row setup
    onInsertRow = false;
    insertRow = null;

    // set the warninings
    sqlwarn = new SQLWarning();
    rowsetWarning = new RowSetWarning();

}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Provides a <code>CachedRowSetImpl</code> instance with the same default properties as
 * as the zero parameter constructor.//from w  ww .j  a v a2  s .  c o m
 * <pre>
 *     onInsertRow = false
 *     insertRow = null
 *     cursorPos = 0
 *     numRows = 0
 *     showDeleted = false
 *     queryTimeout = 0
 *     maxRows = 0
 *     maxFieldSize = 0
 *     rowSetType = ResultSet.TYPE_SCROLL_INSENSITIVE
 *     concurrency = ResultSet.CONCUR_UPDATABLE
 *     readOnly = false
 *     isolation = Connection.TRANSACTION_READ_COMMITTED
 *     escapeProcessing = true
 *     onInsertRow = false
 *     insertRow = null
 *     cursorPos = 0
 *     absolutePos = 0
 *     numRows = 0
 * </pre>
 *
 * However, applications will have the means to specify at runtime the
 * desired <code>SyncProvider</code> object.
 * <p>
 * For example, creating a <code>CachedRowSetImpl</code> object as follows ensures
 * that a it is established with the <code>com.foo.provider.Impl</code> synchronization
 * implementation providing the synchronization mechanism for this disconnected
 * <code>RowSet</code> object.
 * <pre>
 *     Hashtable env = new Hashtable();
 *     env.put(javax.sql.rowset.spi.SyncFactory.ROWSET_PROVIDER_NAME,
 *         "com.foo.provider.Impl");
 *     CachedRowSetImpl crs = new CachedRowSet(env);
 * </pre>
 * <p>
 * Calling this constructor with a <code>null</code> parameter will
 * cause the <code>SyncFactory</code> to provide the reference
 * optimistic provider <code>com.sun.rowset.providers.RIOptimisticProvider</code>.
 * <p>
 * In addition, the following properties can be associated with the
 * provider to assist in determining the choice of the synchronizaton
 * provider such as:
 * <ul>
 * <li><code>ROWSET_SYNC_PROVIDER</code> - the property specifying the the
 * <code>SyncProvider</code> class name to be instantiated by the
 * <code>SyncFacttory</code>
 * <li><code>ROWSET_SYNC_VENDOR</code> - the property specifying the software
 * vendor associated with a <code>SyncProvider</code> implementation.
 * <li><code>ROWSET_SYNC_PROVIDER_VER</code> - the property specifying the
 * version of the <code>SyncProvider</code> implementation provided by the
 * software vendor.
 * </ul>
 * More specific detailes are available in the <code>SyncFactory</code>
 * and <code>SyncProvider</code> specificiations later in this document.
 * <p>
 * @param env a <code>Hashtable</code> object with a list of desired
 *        synchronization providers
 * @throws SQLException if the requested provider cannot be found by the
 * synchonization factory
 * @see SyncProvider
 */

public BFTRowSet(Hashtable<String, String> env) throws SQLException {
    try {
        resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle();
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }

    if (env == null) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.nullhash").toString());
    }

    String providerName = env.get(javax.sql.rowset.spi.SyncFactory.ROWSET_SYNC_PROVIDER);

    // set the Reader, this maybe overridden latter
    provider = (SyncProvider) SyncFactory.getInstance(providerName);

    rowSetReader = provider.getRowSetReader();
    rowSetWriter = provider.getRowSetWriter();

    initParams(); // allocate the parameters collection
    initContainer();
    initProperties(); // set up some default values
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Sets the active <code>SyncProvider</code> and attempts to load
 * load the new provider using the <code>SyncFactory</code> SPI.
 *
 * @throws SQLException if an error occurs while resetting the
 *          <code>SyncProvider</code>.
 *//*from   w w  w .j a  v a 2 s.  c om*/
public void setSyncProvider(String providerStr) throws SQLException {
    provider = (SyncProvider) SyncFactory.getInstance(providerStr);

    rowSetReader = provider.getRowSetReader();
    rowSetWriter = provider.getRowSetWriter();
}