当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.CONCUR_UPDATABLE属性代码示例

本文整理汇总了Java中java.sql.ResultSet.CONCUR_UPDATABLE属性的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.CONCUR_UPDATABLE属性的具体用法?Java ResultSet.CONCUR_UPDATABLE怎么用?Java ResultSet.CONCUR_UPDATABLE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.sql.ResultSet的用法示例。


在下文中一共展示了ResultSet.CONCUR_UPDATABLE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: supportsResultSetConcurrency

/**
 * JDBC 2.0 Does the database support the concurrency type in combination
 * with the given result set type?
 * 
 * @param type
 *            defined in java.sql.ResultSet
 * @param concurrency
 *            type defined in java.sql.ResultSet
 * @return true if so
 * @exception SQLException
 *                if a database-access error occurs.
 * @see Connection
 */
public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
    switch (type) {
        case ResultSet.TYPE_SCROLL_INSENSITIVE:
            if ((concurrency == ResultSet.CONCUR_READ_ONLY) || (concurrency == ResultSet.CONCUR_UPDATABLE)) {
                return true;
            }
            throw SQLError.createSQLException("Illegal arguments to supportsResultSetConcurrency()", SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
                    getExceptionInterceptor());

        case ResultSet.TYPE_FORWARD_ONLY:
            if ((concurrency == ResultSet.CONCUR_READ_ONLY) || (concurrency == ResultSet.CONCUR_UPDATABLE)) {
                return true;
            }
            throw SQLError.createSQLException("Illegal arguments to supportsResultSetConcurrency()", SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
                    getExceptionInterceptor());

        case ResultSet.TYPE_SCROLL_SENSITIVE:
            return false;
        default:
            throw SQLError.createSQLException("Illegal arguments to supportsResultSetConcurrency()", SQLError.SQL_STATE_ILLEGAL_ARGUMENT,
                    getExceptionInterceptor());
    }

}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:37,代码来源:DatabaseMetaData.java

示例2: JDBCResultSet

/**
 * Constructs a new <code>JDBCResultSet</code> object using the specified
 * navigator and <code>org.hsqldb.result.ResultMetaData</code>.
 *
 * <p>
 *
 * @param s the statement
 * @param r the internal result form that the new
 *   <code>JDBCResultSet</code> represents
 * @param metaData ResultMetaData
 * @param props the connection properties
 * @throws SQLException when the supplied Result is of type
 *   org.hsqldb.Result.ERROR
 */
JDBCResultSet(SessionInterface session, JDBCStatementBase s, Result r,
              ResultMetaData metaData,
              HsqlProperties props) throws SQLException {

    this.session   = session;
    this.statement = s;
    this.result    = r;
    connProperties = props;
    rsScrollabilty = r.rsScrollability;
    rsConcurrency  = r.rsConcurrency;
    rsHoldability  = r.rsHoldability;
    navigator      = r.getNavigator();
    resultMetaData = metaData;
    columnCount    = resultMetaData.getColumnCount();

    if (rsConcurrency == ResultSet.CONCUR_UPDATABLE) {
        rsInsertability = true;

        for (int i = 0; i < metaData.colIndexes.length; i++) {
            if (metaData.colIndexes[i] < 0) {
                rsInsertability = false;

                break;
            }
        }
        preparedStatement = new JDBCPreparedStatement(s.connection,
                result);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:43,代码来源:JDBCResultSet.java

示例3: unpackBinaryResultSetRow

/**
 * Un-packs binary-encoded result set data for one row
 * 
 * @param fields
 * @param binaryData
 * @param resultSetConcurrency
 * 
 * @return byte[][]
 * 
 * @throws SQLException
 */
private final ResultSetRow unpackBinaryResultSetRow(Field[] fields, Buffer binaryData, int resultSetConcurrency) throws SQLException {
    int numFields = fields.length;

    byte[][] unpackedRowData = new byte[numFields][];

    //
    // Unpack the null bitmask, first
    //

    int nullCount = (numFields + 9) / 8;
    int nullMaskPos = binaryData.getPosition();
    binaryData.setPosition(nullMaskPos + nullCount);
    int bit = 4; // first two bits are reserved for future use

    //
    // TODO: Benchmark if moving check for updatable result sets out of loop is worthwhile?
    //

    for (int i = 0; i < numFields; i++) {
        if ((binaryData.readByte(nullMaskPos) & bit) != 0) {
            unpackedRowData[i] = null;
        } else {
            if (resultSetConcurrency != ResultSet.CONCUR_UPDATABLE) {
                extractNativeEncodedColumn(binaryData, fields, i, unpackedRowData);
            } else {
                unpackNativeEncodedColumn(binaryData, fields, i, unpackedRowData);
            }
        }

        if (((bit <<= 1) & 255) == 0) {
            bit = 1; /* To next byte */

            nullMaskPos++;
        }
    }

    return new ByteArrayRow(unpackedRowData, getExceptionInterceptor());
}
 
开发者ID:bragex,项目名称:the-vigilantes,代码行数:49,代码来源:MysqlIO.java

示例4: rowSetConcurrencyTypes

@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:CommonRowSetTests.java

示例5: getMetaData

/**
 * <!-- start generic documentation -->
 * Retrieves a <code>ResultSetMetaData</code> object that contains
 * information about the columns of the <code>ResultSet</code> object
 * that will be returned when this <code>PreparedStatement</code> object
 * is executed.
 * <P>
 * Because a <code>PreparedStatement</code> object is precompiled, it is
 * possible to know about the <code>ResultSet</code> object that it will
 * return without having to execute it.  Consequently, it is possible
 * to invoke the method <code>getMetaData</code> on a
 * <code>PreparedStatement</code> object rather than waiting to execute
 * it and then invoking the <code>ResultSet.getMetaData</code> method
 * on the <code>ResultSet</code> object that is returned.
 * <P>
 * <B>NOTE:</B> Using this method may be expensive for some drivers due
 * to the lack of underlying DBMS support.
 * <!-- end generic documentation -->
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * Since 1.7.2, this feature is supported and is <em>inexpensive</em> as
 * it is backed by underlying DBMS support.  If the statement
 * generates an update count, then null is returned.
 * </div>
 * <!-- end release-specific documentation -->
 * @return the description of a <code>ResultSet</code> object's columns or
 *         <code>null</code> if the driver cannot return a
 *         <code>ResultSetMetaData</code> object
 * @exception SQLException if a database access error occurs or
 * this method is called on a closed <code>PreparedStatement</code>
 * @exception SQLFeatureNotSupportedException if the JDBC driver does not support
 * this method
 * @since JDK 1.2 (JDK 1.1.x developers: read the overview for
 *   JDBCParameterMetaData)
 */
public synchronized ResultSetMetaData getMetaData() throws SQLException {

    checkClosed();

    if (statementRetType != StatementTypes.RETURN_RESULT) {
        return null;
    }

    if (resultSetMetaData == null) {
        boolean isUpdatable  = rsConcurrency == ResultSet.CONCUR_UPDATABLE;
        boolean isInsertable = isUpdatable;

        if (isInsertable) {
            for (int i = 0; i < resultMetaData.colIndexes.length; i++) {
                if (resultMetaData.colIndexes[i] < 0) {
                    isInsertable = false;

                    break;
                }
            }
        }
        resultSetMetaData = new JDBCResultSetMetaData(resultMetaData,
                isUpdatable, isInsertable, connection.connProperties);
    }

    return resultSetMetaData;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:65,代码来源:JDBCPreparedStatement.java

示例6: getMetaData

/**
 * <!-- start generic documentation -->
 * Retrieves the  number, types and properties of
 * this <code>ResultSet</code> object's columns.
 * <!-- end generic documentation -->
 *
 * <!-- start release-specific documentation -->
 * <div class="ReleaseSpecificDocumentation">
 * <h3>HSQLDB-Specific Information:</h3> <p>
 *
 * <B>Example:</B> <p>
 *
 * The following code fragment creates a <code>ResultSet</code> object rs,
 * creates a <code>ResultSetMetaData</code> object rsmd, and uses rsmd
 * to find out how many columns rs has and whether the first column
 * in rs can be used in a <code>WHERE</code> clause. <p>
 *
 * <pre class="JavaCodeExample">
 * ResultSet rs   = stmt.<b>executeQuery</b>(<span class="JavaStringLiteral">"SELECT a, b, c FROM TABLE2"</span>);
 * ResultSetMetaData rsmd = rs.<b>getMetaData</b>();<br>
 * int numberOfColumns = rsmd.<b>getColumnCount</b>();<br>
 * boolean b = rsmd.<b>isSearchable</b>(1);<br>
 * </pre>
 *
 * <hr>
 *
 * <B>Changes:</B> <p>
 *
 * With version 1.9.0, the engine's SQL implementation has been
 * completely rewritten. Changes to this class and the implementation of
 * ResultSetMetaData reflect the engine's new capabilities and provide
 * more accurate information. <p>
 *
 * changes to consider: <p>
 *
 * <ol>
 * <li>isAutoIncrement(int) <i>always</i> returned <code>false</code></li>
 * <li>isNullable(int) returns the nullability of a real table or view
 *     column in the ResultSet and returns
 *     <code>columnNoNulls</code> for non-base-column ResultSet columns
 *     (columns of the ResultSet that are based on expressions or
 *     aggregates).</li>
 * <li>getColumnDisplaySize(int) returns correct results even for expression
 *     columns.</li>
 * <li>getPrecision(int) returns the correct precision even for expression
 *     columns.</li>
 * <li>getScale(int) returns the correct precision even for expression
 *     columns.</li>
 * <li>getCatalogName(int) returns the catalog name of the database.</li>
 * </ol> <p>
 *
 * <hr>
 * </div>
 * <!-- end release-specific documentation -->
 *
 * @return the description of this <code>ResultSet</code> object's columns
 * @exception SQLException if a database access error occurs or this method is
 *            called on a closed result set
 * @see JDBCResultSetMetaData
 */
public ResultSetMetaData getMetaData() throws SQLException {

    checkClosed();

    if (resultSetMetaData == null) {
        boolean isUpdatable = rsConcurrency == ResultSet.CONCUR_UPDATABLE;

        resultSetMetaData = new JDBCResultSetMetaData(resultMetaData,
                isUpdatable, rsInsertability, connProperties);
    }

    return resultSetMetaData;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:73,代码来源:JDBCResultSet.java


注:本文中的java.sql.ResultSet.CONCUR_UPDATABLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。