Java Code Examples for java.sql.ResultSet#TYPE_FORWARD_ONLY

The following examples show how to use java.sql.ResultSet#TYPE_FORWARD_ONLY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static int getJdbcResultSetType(byte thriftType) {
  switch (thriftType) {
    case gfxdConstants.RESULTSET_TYPE_FORWARD_ONLY:
      return ResultSet.TYPE_FORWARD_ONLY;
    case gfxdConstants.RESULTSET_TYPE_INSENSITIVE:
      return ResultSet.TYPE_SCROLL_INSENSITIVE;
    case gfxdConstants.RESULTSET_TYPE_SENSITIVE:
      return ResultSet.TYPE_SCROLL_SENSITIVE;
    default:
      throw new IllegalArgumentException("Thrift ResultSet type="
          + thriftType);
  }
}
 
Example 2
Source File: AvaticaClosedStatementTest.java    From calcite-avatica with Apache License 2.0 5 votes vote down vote up
@Override protected Statement newInstance() throws Exception {
  UnregisteredDriver driver = new TestDriver();
  AvaticaConnection connection = new AvaticaConnection(driver, driver.createFactory(),
      "jdbc:avatica", new Properties()) {
  };
  StatementHandle handle = mock(StatementHandle.class);
  AvaticaStatement statement = new AvaticaStatement(connection, handle,
      ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
      ResultSet.HOLD_CURSORS_OVER_COMMIT) {
  };
  statement.close();
  assertTrue("Statement is not closed", statement.isClosed());

  return statement;
}
 
Example 3
Source File: PrestoDatabaseMetaData.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public boolean supportsResultSetConcurrency(int type, int concurrency)
        throws SQLException
{
    return (type == ResultSet.TYPE_FORWARD_ONLY) &&
            (concurrency == ResultSet.CONCUR_READ_ONLY);
}
 
Example 4
Source File: PhoenixConnection.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
    if (resultSetType != ResultSet.TYPE_FORWARD_ONLY || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
        throw new SQLFeatureNotSupportedException();
    }
    return createStatement();
}
 
Example 5
Source File: CommonRowSetTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetScrollTypes")
protected Object[][] rowSetScrollTypes() throws Exception {
    RowSet rs = newInstance();

    return new Object[][]{
        {rs, ResultSet.TYPE_FORWARD_ONLY},
        {rs, ResultSet.TYPE_SCROLL_INSENSITIVE},
        {rs, ResultSet.TYPE_SCROLL_SENSITIVE}
    };
}
 
Example 6
Source File: DefaultResultSetHandler.java    From mybatis with Apache License 2.0 5 votes vote down vote up
private void skipRows(ResultSet rs, RowBounds rowBounds) throws SQLException {
  if (rs.getType() != ResultSet.TYPE_FORWARD_ONLY) {
    if (rowBounds.getOffset() != RowBounds.NO_ROW_OFFSET) {
      rs.absolute(rowBounds.getOffset());
    }
  } else {
    for (int i = 0; i < rowBounds.getOffset(); i++) {
      rs.next();
    }
  }
}
 
Example 7
Source File: CommonRowSetTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetScrollTypes")
protected Object[][] rowSetScrollTypes() throws Exception {
    RowSet rs = newInstance();

    return new Object[][]{
        {rs, ResultSet.TYPE_FORWARD_ONLY},
        {rs, ResultSet.TYPE_SCROLL_INSENSITIVE},
        {rs, ResultSet.TYPE_SCROLL_SENSITIVE}
    };
}
 
Example 8
Source File: VTIDeferModPolicy.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * See if a VTI modification statement should be deferred.
 *
 * @param statementType DeferModification.INSERT_STATEMENT, UPDATE_STATEMENT, or DELETE_STATEMENT
 * @param targetVTI The target VTI
 * @param updateColumnNames The list of columns being updated, null if this is not an update statement
 * @param source
 */
public static boolean deferIt( int statementType,
                               FromVTI targetVTI,
                               String[] updateColumnNames,
                               QueryTreeNode source)
    throws StandardException
{
    try
    {
        DeferModification deferralControl;
        int resultSetType = targetVTI.getResultSetType( );

        /* Deferred updates and deletes are implemented by scrolling the result set. So, if
         * the statement is an update or delete but the result set is not scrollable then do
         * not attempt to defer the statement.
         */
        if( (statementType == DeferModification.UPDATE_STATEMENT ||statementType == DeferModification.DELETE_STATEMENT)
            && resultSetType == ResultSet.TYPE_FORWARD_ONLY)
            return false;

        deferralControl = targetVTI.getDeferralControl();
        if( deferralControl == null)
        {
            String VTIClassName = targetVTI.getMethodCall().getJavaClassName();
            deferralControl = new DefaultVTIModDeferPolicy( VTIClassName,
                                                            ResultSet.TYPE_SCROLL_SENSITIVE == resultSetType);
        }
        if( deferralControl.alwaysDefer( statementType))
            return true;

        if( source == null && statementType != DeferModification.UPDATE_STATEMENT)
            return false;

        VTIDeferModPolicy deferralSearch = new VTIDeferModPolicy( targetVTI,
                                                                  updateColumnNames,
                                                                  deferralControl,
                                                                  statementType);

        if( source != null)
            source.accept( deferralSearch);

        if( statementType == DeferModification.UPDATE_STATEMENT)
        {
            // Apply the columnRequiresDefer method to updated columns not in the where clause.
            Enumeration columns = deferralSearch.columns.keys();
            while( columns.hasMoreElements())
            {
                if( deferralControl.columnRequiresDefer( statementType,
                                                         (String) columns.nextElement(),
                                                         false))
                    return true;
            }
        }
        return deferralSearch.deferred;
    }
    catch( SQLException sqle)
    {
        throw StandardException.unexpectedUserException(sqle);
    }
}
 
Example 9
Source File: PhoenixStatement.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public int getResultSetType() throws SQLException {
    return ResultSet.TYPE_FORWARD_ONLY;
}
 
Example 10
Source File: CircuitBreakerResultSet.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
@Override
public int getType() {
    return ResultSet.TYPE_FORWARD_ONLY;
}
 
Example 11
Source File: PhoenixResultSet.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public int getType() throws SQLException {
    return ResultSet.TYPE_FORWARD_ONLY;
}
 
Example 12
Source File: DRDAResultSet.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * This method resets the state of this DRDAResultset object so that it can
 * be re-used. This method should reset all variables of this class.
 * 
 */
protected void reset() {
	explicitlyClosed = false;
	state = NOT_OPENED;
	hasdata = true;
	rsLens = null;
	rsDRDATypes = null;
	rsPrecision = null;
	rsScale = null;
	
	outovr_drdaType = null;
	
	withHoldCursor = 0;	
	scrollType = ResultSet.TYPE_FORWARD_ONLY;
	concurType = 0;
	rowCount = 0;
	rs = null;
	
	blksize = 0;
	maxblkext = 0;	
	outovropt = 0;
	qryclsimp = CodePoint.QRYCLSIMP_NO;	
	qryrelscr = false;
	qryrownbr = 0;
	qryrfrtbl = false;	
	qryscrorn = 0;
	qryrowsns = false; 
	qryblkrst = false;
	qryrtndta = false;	
	qryrowset = 0;
	qryprctyp = 0;
	gotPrctyp = false; 	
	rtnextdta = 0;	
	nbrrow = 0;
	rslsetflg = null;	

	extDtaObjects = null;
	rsExtPositions = null;
	pkgcnstkn = null;
	splitQRYDTA = null;	
}
 
Example 13
Source File: MockResultSet.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
/**
 * iBatis会用到这个方法
 */
public int getType() throws SQLException {
    return ResultSet.TYPE_FORWARD_ONLY;
}
 
Example 14
Source File: StatementOption.java    From shardingsphere with Apache License 2.0 4 votes vote down vote up
public StatementOption(final boolean returnGeneratedKeys) {
    this(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT, returnGeneratedKeys);
}
 
Example 15
Source File: DRDAStatement.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/** 
 * is this a scrollable cursor?
 * return true if this is not a forward only cursor
 */
protected boolean isScrollable()
{
	return (getScrollType() != ResultSet.TYPE_FORWARD_ONLY);
}
 
Example 16
Source File: PhoenixStatement.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public int getResultSetType() throws SQLException {
    return ResultSet.TYPE_FORWARD_ONLY;
}
 
Example 17
Source File: CassandraPreparedStatement.java    From cassandra-jdbc-wrapper with Apache License 2.0 4 votes vote down vote up
CassandraPreparedStatement(CassandraConnection con, String cql) throws SQLException
{    	
    this(con, cql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
 
Example 18
Source File: StatementKeyFactory.java    From gemfirexd-oss with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a key for a query with default settings.
 * <p>
 * Defaults are according to the JDBC standard; result set type will be
 * <code>ResultSet.TYPE_FORWARD_ONLY</code>, concurrency will be
 * <code>ResultSet.CONCUR_READ_ONLY</code> and the statement will not
 * return auto-generated keys.
 *
 * @param sql SQL query string
 * @param schema current compilation schema
 * @param holdability result set holdability
 * @return A statement key.
 */
public static StatementKey newPrepared(
        String sql, String schema, int holdability) {
    return new StatementKey(PREPARED, sql, schema,
            ResultSet.TYPE_FORWARD_ONLY,
            ResultSet.CONCUR_READ_ONLY,
            holdability, Statement.NO_GENERATED_KEYS);
}
 
Example 19
Source File: StatementKeyFactory.java    From gemfirexd-oss with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a key for a query specifying whether auto-generated keys
 * shall be returned.
 * <p>
 * Unspecified settings will be according to the JDBC standard; result set
 * type will be <code>ResultSet.TYPE_FORWARD_ONLY</code>, concurrency will
 * be <code>ResultSet.CONCUR_READ_ONLY</code>.
 *
 * @param sql SQL query string
 * @param schema current compilation schema
 * @param holdability result set holdability
 * @param autogeneratedKeys tells whether or not to reutrn auto-generated
 *      keys
 * @return A statement key.
 */
public static StatementKey newPrepared(
        String sql, String schema, int holdability, int autogeneratedKeys) {
    return new StatementKey(PREPARED, sql, schema,
                            ResultSet.TYPE_FORWARD_ONLY,
                            ResultSet.CONCUR_READ_ONLY,
                            holdability, autogeneratedKeys);
}
 
Example 20
Source File: EmbedDatabaseMetaData.java    From gemfirexd-oss with Apache License 2.0 3 votes vote down vote up
/**
    * JDBC 2.0
    *
    * Does the database support the given result set type?
    *
    * @param type defined in java.sql.ResultSet
    * @return true if so 
    * @see Connection
    */
public boolean supportsResultSetType(int type) {
	if ((type == ResultSet.TYPE_FORWARD_ONLY) ||
	    (type == ResultSet.TYPE_SCROLL_INSENSITIVE)) {
		return true;
	}
   //we don't support TYPE_SCROLL_SENSITIVE yet.
   return false;
}