Java Code Examples for java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE

The following examples show how to use java.sql.ResultSet#TYPE_SCROLL_INSENSITIVE . 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: GFXDServiceImpl.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the resultType if set if not set returns the default
 * java.sql.ResultSet.TYPE_FORWARD_ONLY
 */
static int getResultType(StatementAttrs attrs) {
  int rsType;
  if (attrs != null && attrs.isSetResultSetType()) {
    rsType = attrs.getResultSetType();
  }
  else {
    rsType = gfxdConstants.DEFAULT_RESULTSET_TYPE;
  }
  switch (rsType) {
    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 InternalGemFireError("unknown resultSet type "
          + attrs.getResultSetType());
  }
}
 
Example 2
Source File: CassandraStatement.java    From cassandra-jdbc-wrapper with Apache License 2.0 6 votes vote down vote up
CassandraStatement(CassandraConnection con, String cql, int resultSetType, int resultSetConcurrency,
                   int resultSetHoldability) throws SQLException
{
    this.connection = con;
    this.cql = cql;
    this.batchQueries = Lists.newArrayList();
    
    this.consistencyLevel = con.defaultConsistencyLevel;

    if (!(resultSetType == ResultSet.TYPE_FORWARD_ONLY
          || resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE
          || resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)) throw new SQLSyntaxErrorException(BAD_TYPE_RSET);
    this.resultSetType = resultSetType;

    if (!(resultSetConcurrency == ResultSet.CONCUR_READ_ONLY
          || resultSetConcurrency == ResultSet.CONCUR_UPDATABLE)) throw new SQLSyntaxErrorException(BAD_TYPE_RSET);
    this.resultSetConcurrency = resultSetConcurrency;


    if (!(resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT
          || resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT))
        throw new SQLSyntaxErrorException(BAD_HOLD_RSET);
    this.resultSetHoldability = resultSetHoldability;
}
 
Example 3
Source File: SimpleSQLReportDataFactory.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public int getBestResultSetType( final DataRow dataRow ) throws SQLException {
  if ( globalConfig != null && "simple".equalsIgnoreCase( globalConfig.getConfigProperty( //$NON-NLS-1$
          ResultSetTableModelFactory.RESULTSET_FACTORY_MODE ) ) ) { //$NON-NLS-1$
    return ResultSet.TYPE_FORWARD_ONLY;
  }

  final Connection connection = getConnection( dataRow );
  final boolean supportsScrollInsensitive =
      connection.getMetaData().supportsResultSetType( ResultSet.TYPE_SCROLL_INSENSITIVE );
  final boolean supportsScrollSensitive =
      connection.getMetaData().supportsResultSetType( ResultSet.TYPE_SCROLL_SENSITIVE );

  if ( supportsScrollInsensitive ) {
    return ResultSet.TYPE_SCROLL_INSENSITIVE;
  }
  if ( supportsScrollSensitive ) {
    return ResultSet.TYPE_SCROLL_SENSITIVE;
  }
  return ResultSet.TYPE_FORWARD_ONLY;
}
 
Example 4
Source File: GFXDServiceImpl.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the resultType if set if not set returns the default
 * java.sql.ResultSet.TYPE_FORWARD_ONLY
 */
static int getResultType(StatementAttrs attrs) {
  int rsType;
  if (attrs != null && attrs.isSetResultSetType()) {
    rsType = attrs.getResultSetType();
  }
  else {
    rsType = gfxdConstants.DEFAULT_RESULTSET_TYPE;
  }
  switch (rsType) {
    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 InternalGemFireError("unknown resultSet type "
          + attrs.getResultSetType());
  }
}
 
Example 5
Source File: CommonRowSetTests.java    From hottub 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: EmbedConnection.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private int setResultSetType(int resultSetType) {
	/* Add warning if scroll sensitive cursor
	 * and downgrade to scroll insensitive cursor.
	 */
	if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)
	{
		addWarning(SQLWarningFactory.newSQLWarning(SQLState.NO_SCROLL_SENSITIVE_CURSORS));
		resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
	}
	return resultSetType;
}
 
Example 7
Source File: EmbedDatabaseMetaData.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
    * JDBC 2.0
    *
    * Determine whether or not a visible row update can be detected by 
    * calling ResultSet.rowUpdated().
    *
    * @param type result set type, i.e. ResultSet.TYPE_XXX
    * @return true if updates are detected by the resultset type
    */
   public boolean updatesAreDetected(int type) {
	if (type == ResultSet.TYPE_SCROLL_INSENSITIVE) {
		return true;
	} else {
		// For forward only resultsets, we move to before the next
		// row after a update and that is why updatesAreDetected
		// returns false.
		return false;
	}
}
 
Example 8
Source File: QueryExecuter.java    From barleydb with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static int getResultSetType(RuntimeProperties props) throws BarleyDBQueryException {
    if (props.getScrollType() == null) {
        return ResultSet.TYPE_FORWARD_ONLY;
    }
    switch(props.getScrollType()) {
        case FORWARD_ONLY:
            return ResultSet.TYPE_FORWARD_ONLY;
        case SCROLL_INSENSITIVE:
            return ResultSet.TYPE_SCROLL_INSENSITIVE;
        case SCROLL_SENSITIVE:
            return ResultSet.TYPE_SCROLL_SENSITIVE;
        default:
            throw new IllegalQueryStateException("Unknown scroll type '" + props.getScrollType() + "'");
    }
}
 
Example 9
Source File: Converters.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static int getThriftResultSetType(int jdbcType) {
  switch (jdbcType) {
    case ResultSet.TYPE_FORWARD_ONLY:
      return gfxdConstants.RESULTSET_TYPE_FORWARD_ONLY;
    case ResultSet.TYPE_SCROLL_INSENSITIVE:
      return gfxdConstants.RESULTSET_TYPE_INSENSITIVE;
    case ResultSet.TYPE_SCROLL_SENSITIVE:
      return gfxdConstants.RESULTSET_TYPE_SENSITIVE;
    default:
      return gfxdConstants.RESULTSET_TYPE_UNKNOWN;
  }
}
 
Example 10
Source File: EmbedDatabaseMetaData.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
    * JDBC 2.0
    *
    * Determine whether or not a visible row update can be detected by 
    * calling ResultSet.rowUpdated().
    *
    * @param type result set type, i.e. ResultSet.TYPE_XXX
    * @return true if updates are detected by the resultset type
    */
   public boolean updatesAreDetected(int type) {
	if (type == ResultSet.TYPE_SCROLL_INSENSITIVE) {
		return true;
	} else {
		// For forward only resultsets, we move to before the next
		// row after a update and that is why updatesAreDetected
		// returns false.
		return false;
	}
}
 
Example 11
Source File: SQLExecutionHelper.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Determine if DBMS/Driver supports scrollable resultsets to be able to
 * determine complete row count for a given SQL.
 *
 * @param conn established JDBC connection
 * @param dc connection information
 * @param sql the sql to be executed
 */
private void updateScrollableSupport(Connection conn, DatabaseConnection dc,
        String sql) {
    useScrollableCursors = dc.isUseScrollableCursors();
    if (!useScrollableCursors) {
        return;
    }
    String driverName = dc.getDriverClass();
    /* Derby fails to support scrollable cursors when invoking 'stored procedures'
     which return resultsets - it fails hard: not throwing a SQLException,
     but terminating the connection - so don't try to use scrollable cursor
     on derby, for "non"-selects */
    if (driverName != null && driverName.startsWith("org.apache.derby")) { //NOI18N
        if (!isSelectStatement(sql)) {
            resultSetScrollType = ResultSet.TYPE_FORWARD_ONLY;
            return;
        }
    }
    /* Try to get a "good" scrollable ResultSet and follow the DBs support */
    try {
        if (conn.getMetaData().supportsResultSetType(
                ResultSet.TYPE_SCROLL_INSENSITIVE)) {
            resultSetScrollType = ResultSet.TYPE_SCROLL_INSENSITIVE;
        } else if (conn.getMetaData().supportsResultSetType(
                ResultSet.TYPE_SCROLL_SENSITIVE)) {
            resultSetScrollType = ResultSet.TYPE_SCROLL_SENSITIVE;
        }
    } catch (Exception ex) {
        LOGGER.log(Level.WARNING, "Exception while querying" //NOI18N
                + " database for scrollable resultset support"); //NOI18N
    }
}
 
Example 12
Source File: CommonRowSetTests.java    From openjdk-jdk8u 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 13
Source File: EmbedConnection.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
private int setResultSetType(int resultSetType) {

		/* Add warning if scroll sensitive cursor
		 * and downgrade to scroll insensitive cursor.
		 */
		if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)
		{
			addWarning(SQLWarningFactory.newSQLWarning(SQLState.NO_SCROLL_SENSITIVE_CURSORS));
			resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
		}
		return resultSetType;
	}
 
Example 14
Source File: CommonRowSetTests.java    From TencentKona-8 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 15
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 16
Source File: ESResultSet.java    From sql4es with Apache License 2.0 4 votes vote down vote up
@Override
public int getType() throws SQLException {
	return ResultSet.TYPE_SCROLL_INSENSITIVE;
}
 
Example 17
Source File: EmbedDatabaseMetaData.java    From gemfirexd-oss with Apache License 2.0 3 votes vote down vote up
/**
    * JDBC 2.0
    *
    * Determine whether a result set's updates are visible.
    *
    * @param type result set type, i.e. ResultSet.TYPE_XXX
    * @return true if updates are visible for the result set type
    */
   public boolean ownUpdatesAreVisible(int type)   {
		if (type == ResultSet.TYPE_SCROLL_INSENSITIVE) {
			return true;
		} else {
			return false;
		}
}
 
Example 18
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;
}
 
Example 19
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;
}
 
Example 20
Source File: cfQueryResultData.java    From openbd-core with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Retrieves the type of this <code>ResultSet</code> object.  
 * The type is determined by the <code>Statement</code> object
 * that created the result set.
 *
 * @return <code>ResultSet.TYPE_FORWARD_ONLY</code>,
 *         <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>,
 *         or <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>
 * @exception SQLException if a database access error occurs
 * @since 1.2
 */
public int getType() throws SQLException {
	return ResultSet.TYPE_SCROLL_INSENSITIVE;
}