Java Code Examples for java.sql.ResultSet#CONCUR_UPDATABLE

The following examples show how to use java.sql.ResultSet#CONCUR_UPDATABLE . 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: ClientDBMetaData.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean supportsResultSetConcurrency(int type, int concurrency)
    throws SQLException {
  this.conn.lock();
  try {
    initServiceMetaData();
    List<Integer> supportedRSTypes;
    switch (concurrency) {
      case ResultSet.CONCUR_READ_ONLY:
        supportedRSTypes = this.serviceMetaData.getFeaturesWithParams().get(
            ServiceFeatureParameterized.RESULTSET_CONCURRENCY_READ_ONLY);
        break;
      case ResultSet.CONCUR_UPDATABLE:
        supportedRSTypes = this.serviceMetaData.getFeaturesWithParams().get(
            ServiceFeatureParameterized.RESULTSET_CONCURRENCY_UPDATABLE);
        break;
      default:
        return false;
    }
    return supportedRSTypes != null
        && supportedRSTypes.contains(Converters.getThriftResultSetType(type));
  } finally {
    this.conn.unlock();
  }
}
 
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: CachedResultSet.java    From jTDS with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructs a cached result set based on locally generated data.
 *
 * @param statement the parent statement object
 * @param colName   array of column names
 * @param colType   array of corresponding data types
 * @exception SQLException if an error occurs
 */
CachedResultSet(JtdsStatement statement,
                String[] colName, int[] colType) throws SQLException {
    super(statement, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE, null);
    //
    // Construct the column descriptor array
    //
    columns = new ColInfo[colName.length];
    for (int i = 0; i < colName.length; i++) {
        ColInfo ci = new ColInfo();
        ci.name     = colName[i];
        ci.realName = colName[i];
        ci.jdbcType = colType[i];
        ci.isCaseSensitive = false;
        ci.isIdentity = false;
        ci.isWriteable = false;
        ci.nullable = 2;
        ci.scale = 0;
        TdsData.fillInType(ci);
        columns[i] = ci;
    }
    columnCount   = getColumnCount(columns);
    rowData       = new ArrayList(INITIAL_ROW_COUNT);
    rowsInResult  = 0;
    pos           = POS_BEFORE_FIRST;
    tempResultSet = true;
    cursorName    = null;
    procName      = null;
    procedureParams = null;
}
 
Example 4
Source File: ClientStatement.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
ClientStatement(ClientConnection conn, int rsType, int rsConcurrency,
    int rsHoldability) {
  this(conn, conn.getHoldability());
  this.attrs.setResultSetType((byte)Converters
      .getThriftResultSetType(rsType));
  if (rsConcurrency == ResultSet.CONCUR_UPDATABLE) {
    this.attrs.setUpdatable(true);
  }
  this.isOpen = true;
}
 
Example 5
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 6
Source File: StatementKeyFactoryTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void testUnequalityVarious() {
    String sql = "select * from sys.systables";
    String schema = "APP";
    int rsh = ResultSet.HOLD_CURSORS_OVER_COMMIT;
    int rst = ResultSet.TYPE_SCROLL_INSENSITIVE;
    int rsc = ResultSet.CONCUR_UPDATABLE;
    int auto = Statement.RETURN_GENERATED_KEYS;
    // Create a one key of each type, all different from each other.
    StatementKey[] keys = new StatementKey[] {
        StatementKeyFactory.newPrepared(sql, schema, rsh),
        StatementKeyFactory.newPrepared(sql, schema, rsh, auto),
        StatementKeyFactory.newPrepared(sql, schema, rst, rsc, rsh),
        StatementKeyFactory.newCallable(sql, schema, rsh),
        StatementKeyFactory.newCallable(sql, schema, rst, rsc, rsh)};
    for (int outer=0; outer < keys.length; outer++) {
        StatementKey current = keys[outer];
        for (int inner=0; inner < keys.length; inner++) {
            if (outer != inner) {
                if (current.equals(keys[inner])) {
                    fail("[" + current.toString() + "] should not equal [" +
                            keys[inner].toString() + "]");
                }
            } else {
                // Should equal itself.
                assertTrue(current.equals(keys[inner]));
            }
        }
    }
}
 
Example 7
Source File: CommonRowSetTests.java    From dragonwell8_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 8
Source File: ClientStatement.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
ClientStatement(ClientConnection conn, int rsType, int rsConcurrency,
    int rsHoldability) {
  this(conn, conn.getHoldability());
  this.attrs.setResultSetType((byte)Converters
      .getThriftResultSetType(rsType));
  if (rsConcurrency == ResultSet.CONCUR_UPDATABLE) {
    this.attrs.setUpdatable(true);
  }
  this.isOpen = true;
}
 
Example 9
Source File: CommonRowSetTests.java    From openjdk-jdk8u-backup 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 10
Source File: CommonRowSetTests.java    From openjdk-jdk8u 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 11
Source File: CommonRowSetTests.java    From jdk8u60 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 12
Source File: CommonRowSetTests.java    From TencentKona-8 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 13
Source File: SURQueryMixTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Test SUR properties of the query
 */
public void runTest() 
    throws SQLException
{
    println(query);
    DatabaseMetaData dbMeta = getConnection().getMetaData();
            
    if (dbMeta.ownDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)) {
        checkRowDeleted = true;
    }
    
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    
    s.setCursorName(cursorName);
    ResultSet rs = s.executeQuery(query);

    checkRowUpdated = dbMeta.ownUpdatesAreVisible(rs.getType());        
    checkRowDeleted = dbMeta.ownDeletesAreVisible(rs.getType());
    
    // Create map with rows
    Map rows = createRowMap(rs);
    
    // Set of rows which are updated (contains Integer with position in RS)
    final Set updatedRows = new HashSet();
    
    // Set of rows which are deleted (contains Integer with position in RS)
    final Set deletedRows = new HashSet();
            
    // Test navigation
    testNavigation(rs, rows, updatedRows, deletedRows);
    
    // Only test updatability if the ResultSet is updatable:
    // (Note: this enables the test do run successfully even if
    // scrollable updatable resultsets are not implemented. 
    // If SUR is not implemented, a well behaved JDBC driver will 
    // downgrade the concurrency mode to READ_ONLY).
    // SUR may be implemented incrementally, i.e first in embedded mode
    // then in the network driver.)
    if (rs.getConcurrency()==ResultSet.CONCUR_UPDATABLE) {
    
        // update a random sample of 2 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 2); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // update a random sample of 5 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 5); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // update a random sample of 10 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 10); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 2 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 2);
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 5 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 5);
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 10 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 10);
        testNavigation(rs, rows, updatedRows, deletedRows); 
    } else {
        assertTrue("ResultSet concurrency downgraded to CONCUR_READ_ONLY",
                   false);
    }
    
    rs.close();
    s.close();
}
 
Example 14
Source File: SURQueryMixTest.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Test SUR properties of the query
 */
public void runTest() 
    throws SQLException
{
    println(query);
    DatabaseMetaData dbMeta = getConnection().getMetaData();
            
    if (dbMeta.ownDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)) {
        checkRowDeleted = true;
    }
    
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    
    s.setCursorName(cursorName);
    ResultSet rs = s.executeQuery(query);

    checkRowUpdated = dbMeta.ownUpdatesAreVisible(rs.getType());        
    checkRowDeleted = dbMeta.ownDeletesAreVisible(rs.getType());
    
    // Create map with rows
    Map rows = createRowMap(rs);
    
    // Set of rows which are updated (contains Integer with position in RS)
    final Set updatedRows = new HashSet();
    
    // Set of rows which are deleted (contains Integer with position in RS)
    final Set deletedRows = new HashSet();
            
    // Test navigation
    testNavigation(rs, rows, updatedRows, deletedRows);
    
    // Only test updatability if the ResultSet is updatable:
    // (Note: this enables the test do run successfully even if
    // scrollable updatable resultsets are not implemented. 
    // If SUR is not implemented, a well behaved JDBC driver will 
    // downgrade the concurrency mode to READ_ONLY).
    // SUR may be implemented incrementally, i.e first in embedded mode
    // then in the network driver.)
    if (rs.getConcurrency()==ResultSet.CONCUR_UPDATABLE) {
    
        // update a random sample of 2 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 2); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // update a random sample of 5 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 5); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // update a random sample of 10 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 10); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 2 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 2);
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 5 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 5);
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 10 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 10);
        testNavigation(rs, rows, updatedRows, deletedRows); 
    } else {
        assertTrue("ResultSet concurrency downgraded to CONCUR_READ_ONLY",
                   false);
    }
    
    rs.close();
    s.close();
}
 
Example 15
Source File: FromVTI.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Get the ResultSetMetaData for the class/object.  We first look for 
 * the optional static method which has the same signature as the constructor.
 * If it doesn't exist, then we instantiate an object and get the ResultSetMetaData
 * from that object.
 *
 * @return The ResultSetMetaData from the class/object.
 *
 * @exception StandardException		Thrown on error
 */
public ResultSetMetaData getResultSetMetaData() 
	throws StandardException
{
	// Get the actual 
	ResultSetMetaData rsmd = null;

	try
	{	
		if (version2)
		{
			ps = (PreparedStatement) getNewInstance();

			if (ps.getResultSetConcurrency() != ResultSet.CONCUR_UPDATABLE)
			{
				throw StandardException.newException(SQLState.LANG_UPDATABLE_VTI_NON_UPDATABLE_RS, 
													 getVTIName());
			}

			rsmd = ps.getMetaData();

               controlsDeferral = (ps instanceof DeferModification);

               /* See if the result set is known to be insensitive or not.
                *
                * Some older VTI implementations do not implement getResultSetType(). UpdatableVTITemplate
                * does not implement it at all. UpdatableVTITemplate.getResultSetType throws an
                * exception. In either of these cases make the conservative assumption that the result set is sensitive.
                */
               try
               {
                   resultSetType = ps.getResultSetType();
               }
               catch( SQLException sqle){}
               catch( java.lang.AbstractMethodError ame){}
               catch( java.lang.NoSuchMethodError nsme){}
               isInsensitive = (resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE);

			if (!implementsVTICosting) {
				ps.close();
				ps = null;
			}

		}
		else
		{
			rs = (ResultSet) getNewInstance();

			rsmd = rs.getMetaData();

			if (!implementsVTICosting) {
				rs.close();
				rs = null;
			}
		}
	}
	catch(Throwable t)
	{
		throw StandardException.unexpectedUserException(t);
	}

	return rsmd;
}
 
Example 16
Source File: SURQueryMixTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * Test SUR properties of the query
 */
public void runTest() 
    throws SQLException
{
    println(query);
    DatabaseMetaData dbMeta = getConnection().getMetaData();
            
    if (dbMeta.ownDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)) {
        checkRowDeleted = true;
    }
    
    Statement s = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
    
    s.setCursorName(cursorName);
    ResultSet rs = s.executeQuery(query);

    checkRowUpdated = dbMeta.ownUpdatesAreVisible(rs.getType());        
    checkRowDeleted = dbMeta.ownDeletesAreVisible(rs.getType());
    
    // Create map with rows
    Map rows = createRowMap(rs);
    
    // Set of rows which are updated (contains Integer with position in RS)
    final Set updatedRows = new HashSet();
    
    // Set of rows which are deleted (contains Integer with position in RS)
    final Set deletedRows = new HashSet();
            
    // Test navigation
    testNavigation(rs, rows, updatedRows, deletedRows);
    
    // Only test updatability if the ResultSet is updatable:
    // (Note: this enables the test do run successfully even if
    // scrollable updatable resultsets are not implemented. 
    // If SUR is not implemented, a well behaved JDBC driver will 
    // downgrade the concurrency mode to READ_ONLY).
    // SUR may be implemented incrementally, i.e first in embedded mode
    // then in the network driver.)
    if (rs.getConcurrency()==ResultSet.CONCUR_UPDATABLE) {
    
        // update a random sample of 2 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 2); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // update a random sample of 5 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 5); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // update a random sample of 10 records
        updateRandomSampleOfNRecords(rs, rows, updatedRows, 10); 
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 2 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 2);
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 5 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 5);
        testNavigation(rs, rows, updatedRows, deletedRows); 
        
        // delete a random sample of 10 records
        deleteRandomSampleOfNRecords(rs, rows, deletedRows, 10);
        testNavigation(rs, rows, updatedRows, deletedRows); 
    } else {
        assertTrue("ResultSet concurrency downgraded to CONCUR_READ_ONLY",
                   false);
    }
    
    rs.close();
    s.close();
}
 
Example 17
Source File: ClientStatement.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int getResultSetConcurrency() throws SQLException {
  return this.attrs.isSetUpdatable() && this.attrs.isUpdatable()
      ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY;
}
 
Example 18
Source File: UpdatableVTITemplate.java    From spliceengine with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * @see java.sql.Statement
 *
	 * @exception SQLException on unexpected JDBC error
 */
public int getResultSetConcurrency() throws SQLException
{
       return ResultSet.CONCUR_UPDATABLE;
}
 
Example 19
Source File: GFXDServiceImpl.java    From gemfirexd-oss with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the Concurrency associated with the statement if set the the input
 * object if not set by default returns java.sql.ResultSet.CONCUR_READ_ONLY
 * 
 * @param attrs
 * @return
 */
static int getResultSetConcurrency(StatementAttrs attrs) {
  return attrs != null && attrs.isSetUpdatable() && attrs.isUpdatable()
      ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY;
}
 
Example 20
Source File: UpdatableVTITemplate.java    From gemfirexd-oss with Apache License 2.0 2 votes vote down vote up
/**
 * @see java.sql.Statement
 *
	 * @exception SQLException on unexpected JDBC error
 */
public int getResultSetConcurrency() throws SQLException
{
       return ResultSet.CONCUR_UPDATABLE;
}