Java Code Examples for java.sql.ResultSet#CONCUR_READ_ONLY

The following examples show how to use java.sql.ResultSet#CONCUR_READ_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: 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 2
Source File: SnowflakeConnectionV1.java    From snowflake-jdbc with Apache License 2.0 6 votes vote down vote up
public PreparedStatement prepareStatement(String sql, boolean skipParsing)
throws SQLException
{
  logger.debug(
      "PreparedStatement prepareStatement(String sql, boolean skipParsing)");
  raiseSQLExceptionIfConnectionIsClosed();
  PreparedStatement stmt = new SnowflakePreparedStatementV1(
      this,
      sql,
      skipParsing,
      ResultSet.TYPE_FORWARD_ONLY,
      ResultSet.CONCUR_READ_ONLY,
      ResultSet.CLOSE_CURSORS_AT_COMMIT);
  openStatements.add(stmt);
  return stmt;
}
 
Example 3
Source File: CommonRowSetTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
Example 4
Source File: CachedResultSet.java    From jTDS with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a cached result set containing one row.
 *
 * @param statement the parent statement object
 * @param columns   the column descriptor array
 * @param data      the row data
 * @throws SQLException if an error occurs
 */
CachedResultSet(JtdsStatement statement,
        ColInfo columns[], Object data[]) throws SQLException {
    super(statement, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, null);
    this.columns       = columns;
    columnCount   = getColumnCount(columns);
    rowData       = new ArrayList(1);
    rowsInResult  = 1;
    pos           = POS_BEFORE_FIRST;
    tempResultSet = true;
    cursorName    = null;
    rowData.add(copyRow(data));
    procName      = null;
    procedureParams = null;
}
 
Example 5
Source File: SnowflakeConnectionV1.java    From snowflake-jdbc with Apache License 2.0 5 votes vote down vote up
public CallableStatement prepareCall(String sql, boolean skipParsing) throws SQLException
{
  logger.debug(
      " public CallableStatement prepareCall(String sql, boolean skipParsing)");
  raiseSQLExceptionIfConnectionIsClosed();
  CallableStatement stmt = new SnowflakeCallableStatementV1(
      this, sql, skipParsing, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
      ResultSet.CLOSE_CURSORS_AT_COMMIT);
  openStatements.add(stmt);
  return stmt;
}
 
Example 6
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 {
    checkOpen();
    if (resultSetType != ResultSet.TYPE_FORWARD_ONLY
            || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
        throw new SQLFeatureNotSupportedException();
    }
    return createStatement();
}
 
Example 7
Source File: QueryExecuter.java    From barleydb with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static int getResultSetConcurrency(RuntimeProperties props) throws BarleyDBQueryException {
    if (props == null) {
        return ResultSet.CONCUR_READ_ONLY;
    }
    switch (props.getConcurrency()) {
        case READ_ONLY:
            return ResultSet.CONCUR_READ_ONLY;
        case UPDATABLE:
            return ResultSet.CONCUR_UPDATABLE;
        default:
            throw new IllegalQueryStateException("Unknown concurrency '" + props.getConcurrency() + "'");
    }
}
 
Example 8
Source File: DRDAStatement.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * This method resets the state of this DRDAStatement object so that it can
 * be re-used. This method should reset all variables of this class except 
 * the following:
    * 1. database - This variable gets initialized in the constructor and by
    * call to setDatabase.
    * 2. members which get initialized in setPkgnamcsn (pkgnamcsn, pkgcnstkn, 
    * pkgid, pkgsn, isolationLevel, cursorName). pkgnamcsn is the key used to 
    * find if the DRDAStatement can be re-used. Hence its value will not change 
    * when the object is re-used.
 * 
 */
protected void reset() 
{
	setTypDefValues();
	
	withHoldCursor = -1;
	scrollType = ResultSet.TYPE_FORWARD_ONLY;	
	concurType = ResultSet.CONCUR_READ_ONLY;
	rowCount = 0;
	rslsetflg = null;
	maxrslcnt = 0;
	ps = null;
	stmtPmeta = null;
	isCall = false;
	procName = null;
	outputTypes = null;
	outputExpected = false;
	stmt = null;
       truncationWarnings = null;
	
	currentDrdaRs.reset();
	resultSetTable = null;
	resultSetKeyList = null;
	numResultSets = 0;
	
	// Clear parameters without releasing storage
	drdaParamState_.clear(false);
	
	nbrrow = 0;
	qryrowset = 0;	
	blksize = 0;		
	maxblkext = 0;	
	outovropt = 0;	
	qryrfrtbl = false;
	qryprctyp = CodePoint.QRYBLKCTL_DEFAULT;

	needsToSendParamData = false;
	explicitlyPrepared = false;
}
 
Example 9
Source File: TResultSet.java    From tddl5 with Apache License 2.0 4 votes vote down vote up
@Override
public int getConcurrency() throws SQLException {
    return ResultSet.CONCUR_READ_ONLY;
}
 
Example 10
Source File: DRDAStatement.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
	 * This method resets the state of this DRDAStatement object so that it can
	 * be re-used. This method should reset all variables of this class except 
	 * the following:
     * 1. database - This variable gets initialized in the constructor and by
     * call to setDatabase.
     * 2. members which get initialized in setPkgnamcsn (pkgnamcsn, pkgcnstkn, 
     * pkgid, pkgsn, isolationLevel, cursorName). pkgnamcsn is the key used to 
     * find if the DRDAStatement can be re-used. Hence its value will not change 
     * when the object is re-used.
	 * 
	 */
	protected void reset() 
	{
		setTypDefValues();
		
		withHoldCursor = -1;
		scrollType = ResultSet.TYPE_FORWARD_ONLY;	
		concurType = ResultSet.CONCUR_READ_ONLY;;
		rowCount = 0;
		rslsetflg = null;
		maxrslcnt = 0;
		ps = null;
		stmtPmeta = null;
		isCall = false;
		procName = null;
		outputTypes = null;
		outputExpected = false;
		stmt = null;
// GemStone changes BEGIN
		pstmt = null;
		sqlText = null;
		sqldaType = 0;
		pstmtParseWriterMark = 0;
		resetBatch();
		executionBeginTime = 0;
		statementAccessFrequency = 0;
// GemStone changes END
		
		currentDrdaRs.reset();
		resultSetTable = null;
		resultSetKeyList = null;
		numResultSets = 0;
		
		// Clear parameters without releasing storage
		drdaParamState_.clear(false);
		
		nbrrow = 0;
		qryrowset = 0;	
		blksize = 0;		
		maxblkext = 0;	
		outovropt = 0;	
		qryrfrtbl = false;
		qryprctyp = CodePoint.QRYBLKCTL_DEFAULT;

		needsToSendParamData = false;
		explicitlyPrepared = false;
	}
 
Example 11
Source File: AbstractCloudSpannerStatement.java    From spanner-jdbc with MIT License 4 votes vote down vote up
@Override
public int getResultSetConcurrency() throws SQLException {
  return ResultSet.CONCUR_READ_ONLY;
}
 
Example 12
Source File: CassandraStatement.java    From cassandra-jdbc-wrapper with Apache License 2.0 4 votes vote down vote up
public int getResultSetConcurrency() throws SQLException
{
    checkNotClosed();
    return ResultSet.CONCUR_READ_ONLY;
}
 
Example 13
Source File: PhoenixResultSet.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public int getConcurrency() throws SQLException {
    return ResultSet.CONCUR_READ_ONLY;
}
 
Example 14
Source File: CassandraStatement.java    From cassandra-jdbc-wrapper with Apache License 2.0 4 votes vote down vote up
CassandraStatement(CassandraConnection con) throws SQLException
{
    this(con, null, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
 
Example 15
Source File: CachedResultSet.java    From jTDS with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Creates a cached result set with the same columns (and optionally data)
 * as an existing result set.
 *
 * @param rs   the result set to copy
 * @param load load data from the supplied result set
 * @throws SQLException if an error occurs
 */
CachedResultSet(JtdsResultSet rs, boolean load) throws SQLException {
    super((JtdsStatement)rs.getStatement(),
            rs.getStatement().getResultSetType(),
            rs.getStatement().getResultSetConcurrency(), null);
    //
    JtdsStatement stmt = ((JtdsStatement) rs.getStatement());
    //
    // OK If the user requested an updateable result set tell them
    // they can't have one!
    //
    if (concurrency != ResultSet.CONCUR_READ_ONLY) {
        concurrency = ResultSet.CONCUR_READ_ONLY;
        stmt.addWarning(new SQLWarning(
            Messages.get("warning.cursordowngraded",
                         "CONCUR_READ_ONLY"), "01000"));
    }
    //
    // If the user requested a scroll sensitive cursor tell them
    // they can't have that either!
    //
    if (resultSetType >= ResultSet.TYPE_SCROLL_SENSITIVE) {
        resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
        stmt.addWarning(new SQLWarning(
            Messages.get("warning.cursordowngraded",
                         "TYPE_SCROLL_INSENSITIVE"), "01000"));
    }

    columns       = rs.getColumns();
    columnCount   = getColumnCount(columns);
    rowData       = new ArrayList(INITIAL_ROW_COUNT);
    rowsInResult  = 0;
    pos           = POS_BEFORE_FIRST;
    tempResultSet = true;
    cursorName    = null;
    procName      = null;
    procedureParams = null;
    //
    // Load result set into buffer
    //
    if (load) {
        while (rs.next()) {
            rowData.add(copyRow(rs.getCurrentRow()));
        }
        rowsInResult  = rowData.size();
    }
}
 
Example 16
Source File: PhoenixStatement.java    From phoenix with Apache License 2.0 4 votes vote down vote up
@Override
public int getResultSetConcurrency() throws SQLException {
    return ResultSet.CONCUR_READ_ONLY;
}
 
Example 17
Source File: AvaticaDatabaseMetaData.java    From calcite-avatica with Apache License 2.0 4 votes vote down vote up
public boolean supportsResultSetConcurrency(
    int type, int concurrency) throws SQLException {
  return type == ResultSet.TYPE_FORWARD_ONLY
      && concurrency == ResultSet.CONCUR_READ_ONLY;
}
 
Example 18
Source File: SnowflakeStatementV1.java    From snowflake-jdbc with Apache License 2.0 4 votes vote down vote up
/**
 * Construct SnowflakeStatementV1
 *
 * @param connection           connection object
 * @param resultSetType        result set type: ResultSet.TYPE_FORWARD_ONLY.
 * @param resultSetConcurrency result set concurrency: ResultSet.CONCUR_READ_ONLY.
 * @param resultSetHoldability result set holdability: ResultSet.CLOSE_CURSORS_AT_COMMIT
 * @throws SQLException if any SQL error occurs.
 */
SnowflakeStatementV1(
    SnowflakeConnectionV1 connection,
    int resultSetType,
    int resultSetConcurrency,
    int resultSetHoldability) throws SQLException
{
  logger.debug(
      " public SnowflakeStatement(SnowflakeConnectionV1 conn)");

  this.connection = connection;

  if (resultSetType != ResultSet.TYPE_FORWARD_ONLY)
  {
    throw new SQLFeatureNotSupportedException(
        String.format("ResultSet type %d is not supported.", resultSetType),
        FEATURE_UNSUPPORTED.getSqlState(),
        FEATURE_UNSUPPORTED.getMessageCode());
  }

  if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY)
  {
    throw new SQLFeatureNotSupportedException(
        String.format("ResultSet concurrency %d is not supported.", resultSetConcurrency),
        FEATURE_UNSUPPORTED.getSqlState(),
        FEATURE_UNSUPPORTED.getMessageCode());
  }

  if (resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT)
  {
    throw new SQLFeatureNotSupportedException(
        String.format("ResultSet holdability %d is not supported.", resultSetHoldability),
        FEATURE_UNSUPPORTED.getSqlState(),
        FEATURE_UNSUPPORTED.getMessageCode());
  }

  this.resultSetType = resultSetType;
  this.resultSetConcurrency = resultSetConcurrency;
  this.resultSetHoldability = resultSetHoldability;

  sfStatement = (connection != null) ?
                new SFStatement(connection.getSfSession()) : null;
}
 
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: 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);
}