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

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

Introduction

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

Prototype

String ROWSET_SYNC_PROVIDER

To view the source code for javax.sql.rowset.spi SyncFactory ROWSET_SYNC_PROVIDER.

Click Source Link

Document

The standard property-id for a synchronization provider implementation name.

Usage

From source file:Main.java

  public Main() {
  try {/*from   w w w.j a  va  2  s.co m*/
    SyncFactory.registerProvider("MySyncProvider");
    Hashtable env = new Hashtable();
    env.put(SyncFactory.ROWSET_SYNC_PROVIDER, "MySyncProvider");
    crs = new CachedRowSetImpl(env);
    crs.execute(); // load data from custom RowSetReader

    System.out.println("Fetching from RowSet...");
    while (crs.next()) {
      displayData();
    }

    if (crs.isAfterLast() == true) {
      System.out.println("We have reached the end");
      System.out.println("crs row: " + crs.getRow());
    }

    System.out.println("And now backwards...");

    while (crs.previous()) {
      displayData();
    } // end while previous

    if (crs.isBeforeFirst()) {
      System.out.println("We have reached the start");
    }

    crs.first();
    if (crs.isFirst()) {
      System.out.println("We have moved to first");
    }

    System.out.println("crs row: " + crs.getRow());

    if (!crs.isBeforeFirst()) {
      System.out.println("We aren't before the first row.");
    }

    crs.last();
    if (crs.isLast()) {
      System.out.println("...and now we have moved to the last");
    }

    System.out.println("crs row: " + crs.getRow());

    if (!crs.isAfterLast()) {
      System.out.println("we aren't after the last.");
    }

  } catch (SQLException e) {
    e.printStackTrace();
    System.err.println("SQLException: " + e.getMessage());
  }
}

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  .ja  va 2  s  .  co  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
}