java.sql.ResultSet#CONCUR_UPDATABLE源码实例Demo

下面列出了java.sql.ResultSet#CONCUR_UPDATABLE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
}
 
源代码2 项目: gemfirexd-oss   文件: ClientDBMetaData.java
/**
 * {@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();
  }
}
 
源代码3 项目: dragonwell8_jdk   文件: CommonRowSetTests.java
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
源代码4 项目: TencentKona-8   文件: CommonRowSetTests.java
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
源代码5 项目: jdk8u60   文件: CommonRowSetTests.java
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
源代码6 项目: openjdk-jdk8u   文件: CommonRowSetTests.java
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: CommonRowSetTests.java
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
源代码8 项目: gemfirexd-oss   文件: ClientStatement.java
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;
}
 
源代码9 项目: jTDS   文件: CachedResultSet.java
/**
 * 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;
}
 
源代码10 项目: gemfirexd-oss   文件: StatementKeyFactoryTest.java
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]));
            }
        }
    }
}
 
源代码11 项目: barleydb   文件: QueryExecuter.java
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() + "'");
    }
}
 
源代码12 项目: gemfirexd-oss   文件: ClientStatement.java
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;
}
 
源代码13 项目: gemfirexd-oss   文件: FromVTI.java
/**
 * 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;
}
 
源代码14 项目: spliceengine   文件: SURQueryMixTest.java
/**
 * 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();
}
 
源代码15 项目: gemfirexd-oss   文件: SURQueryMixTest.java
/**
 * 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();
}
 
源代码16 项目: gemfirexd-oss   文件: SURQueryMixTest.java
/**
 * 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();
}
 
源代码17 项目: gemfirexd-oss   文件: ClientStatement.java
/**
 * {@inheritDoc}
 */
@Override
public int getResultSetConcurrency() throws SQLException {
  return this.attrs.isSetUpdatable() && this.attrs.isUpdatable()
      ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY;
}
 
源代码18 项目: spliceengine   文件: UpdatableVTITemplate.java
/**
 * @see java.sql.Statement
 *
	 * @exception SQLException on unexpected JDBC error
 */
public int getResultSetConcurrency() throws SQLException
{
       return ResultSet.CONCUR_UPDATABLE;
}
 
源代码19 项目: gemfirexd-oss   文件: GFXDServiceImpl.java
/**
 * 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;
}
 
源代码20 项目: gemfirexd-oss   文件: UpdatableVTITemplate.java
/**
 * @see java.sql.Statement
 *
	 * @exception SQLException on unexpected JDBC error
 */
public int getResultSetConcurrency() throws SQLException
{
       return ResultSet.CONCUR_UPDATABLE;
}