Java Code Examples for java.sql.ResultSet.CONCUR_READ_ONLY

The following are Jave code examples for showing how to use CONCUR_READ_ONLY of the java.sql.ResultSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: the-vigilantes   File: DatabaseMetaData.java   View Source Code Vote up 7 votes
/**
 * 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());
    }

}
 
Example 2
Project: BibliotecaPS   File: DatabaseMetaData.java   View Source Code Vote up 6 votes
/**
 * 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());
    }

}
 
Example 3
Project: Saturn   File: SyncConn.java   View Source Code Vote up 5 votes
protected void checkCursor(int rst, int rsc, int rsh) throws SQLException {
    if (rst != ResultSet.TYPE_FORWARD_ONLY)
        throw new SQLException("SQLite only supports TYPE_FORWARD_ONLY cursors");
    if (rsc != ResultSet.CONCUR_READ_ONLY)
        throw new SQLException("SQLite only supports CONCUR_READ_ONLY cursors");
    if (rsh != ResultSet.CLOSE_CURSORS_AT_COMMIT)
        throw new SQLException("SQLite only supports closing cursors at commit");
}
 
Example 4
Project: openjdk-jdk10   File: CommonRowSetTests.java   View Source Code Vote up 5 votes
@DataProvider(name = "rowSetConcurrencyTypes")
protected Object[][] rowSetConcurrencyTypes() throws Exception {
    RowSet rs = newInstance();
    return new Object[][]{
        {rs, ResultSet.CONCUR_READ_ONLY},
        {rs, ResultSet.CONCUR_UPDATABLE}
    };
}
 
Example 5
Project: sstore-soft   File: JDBC4Connection.java   View Source Code Vote up 5 votes
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
    if (resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE && resultSetConcurrency == ResultSet.CONCUR_READ_ONLY)
        return prepareCall(sql);
    checkClosed();
    throw SQLError.noSupport();
}
 
Example 6
Project: iotdb-jdbc   File: TsfileConnection.java   View Source Code Vote up 5 votes
@Override
   public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
    throw new SQLException(
	    String.format("Statement with resultset concurrency %d is not supported", resultSetConcurrency));
}
if (resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE) {
    throw new SQLException(String.format("Statement with resultset type %d is not supported", resultSetType));
}
return new TsfileStatement(this, client, sessionHandle);
   }
 
Example 7
Project: sstore-soft   File: JDBCResultSet.java   View Source Code Vote up 5 votes
private void checkUpdatable() throws SQLException {

        checkClosed();

        if (rsConcurrency == ResultSet.CONCUR_READ_ONLY) {
            throw Util.notUpdatableColumn();
        }
    }
 
Example 8
Project: ProyectoPacientes   File: ServerPreparedStatement.java   View Source Code Vote up 5 votes
@Override
boolean isCursorRequired() throws SQLException {
    // we only create cursor-backed result sets if
    // a) The query is a SELECT
    // b) The server supports it
    // c) We know it is forward-only (note this doesn't preclude updatable result sets)
    // d) The user has set a fetch size
    return this.resultFields != null && this.connection.isCursorFetchEnabled() && getResultSetType() == ResultSet.TYPE_FORWARD_ONLY
            && getResultSetConcurrency() == ResultSet.CONCUR_READ_ONLY && getFetchSize() > 0;
}
 
Example 9
Project: jdk8u-jdk   File: CommonRowSetTests.java   View Source Code Vote up 5 votes
@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
Project: s-store   File: JDBC4DatabaseMetaData.java   View Source Code Vote up 5 votes
@Override
public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException
{
    checkClosed();
    if (type == ResultSet.TYPE_SCROLL_INSENSITIVE && concurrency == ResultSet.CONCUR_READ_ONLY)
        return true;
    return false;
}
 
Example 11
Project: s-store   File: JDBC4Connection.java   View Source Code Vote up 5 votes
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
{
    if (resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE && resultSetConcurrency == ResultSet.CONCUR_READ_ONLY)
        return prepareStatement(sql);
    checkClosed();
    throw SQLError.noSupport();
}
 
Example 12
Project: s-store   File: JDBCResultSet.java   View Source Code Vote up 5 votes
private void checkUpdatable() throws SQLException {

        checkClosed();

        if (rsConcurrency == ResultSet.CONCUR_READ_ONLY) {
            throw Util.notUpdatableColumn();
        }
    }
 
Example 13
Project: OpenVertretung   File: ServerPreparedStatement.java   View Source Code Vote up 5 votes
@Override
boolean isCursorRequired() throws SQLException {
    // we only create cursor-backed result sets if
    // a) The query is a SELECT
    // b) The server supports it
    // c) We know it is forward-only (note this doesn't preclude updatable result sets)
    // d) The user has set a fetch size
    return this.resultFields != null && this.connection.isCursorFetchEnabled() && getResultSetType() == ResultSet.TYPE_FORWARD_ONLY
            && getResultSetConcurrency() == ResultSet.CONCUR_READ_ONLY && getFetchSize() > 0;
}
 
Example 14
Project: agroal   File: MockStatement.java   View Source Code Vote up 4 votes
@Override
default int getResultSetConcurrency() throws SQLException {
    return ResultSet.CONCUR_READ_ONLY;
}
 
Example 15
Project: spanner-jdbc   File: CloudSpannerDatabaseMetaData.java   View Source Code Vote up 4 votes
@Override
public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException
{
	return type == ResultSet.TYPE_FORWARD_ONLY && concurrency == ResultSet.CONCUR_READ_ONLY;
}
 
Example 16
Project: iotdb-jdbc   File: TsfileQueryResultSet.java   View Source Code Vote up 4 votes
@Override
public int getConcurrency() throws SQLException {
	return ResultSet.CONCUR_READ_ONLY;
}
 
Example 17
Project: sstore-soft   File: JDBC4Statement.java   View Source Code Vote up 4 votes
@Override
public int getResultSetConcurrency() throws SQLException
{
    checkClosed();
    return ResultSet.CONCUR_READ_ONLY;
}
 
Example 18
Project: OpenVertretung   File: StatementImpl.java   View Source Code Vote up 4 votes
private boolean useServerFetch() throws SQLException {
    synchronized (checkClosed().getConnectionMutex()) {
        return this.connection.isCursorFetchEnabled() && this.fetchSize > 0 && this.resultSetConcurrency == ResultSet.CONCUR_READ_ONLY
                && this.resultSetType == ResultSet.TYPE_FORWARD_ONLY;
    }
}
 
Example 19
Project: s-store   File: JDBC4Statement.java   View Source Code Vote up 4 votes
@Override
public int getResultSetConcurrency() throws SQLException
{
    checkClosed();
    return ResultSet.CONCUR_READ_ONLY;
}
 
Example 20
Project: s-store   File: JDBC4Connection.java   View Source Code Vote up 3 votes
/**
 * Check if the createStatement() options are supported
 *
 * See http://docs.oracle.com/javase/7/docs/api/index.html?java/sql/DatabaseMetaData.html
 *
 * The following flags are supported:
 *  - The type must either be TYPE_SCROLL_INSENSITIVE or TYPE_FORWARD_ONLY.
 *  - The concurrency must be CONCUR_READ_ONLY.
 *  - The holdability must be CLOSE_CURSORS_AT_COMMIT.
 *
 * @param resultSetType  JDBC result set type option
 * @param resultSetConcurrency  JDBC result set concurrency option
 * @param resultSetHoldability  JDBC result set holdability option
 * @throws SQLException  if not supported
 */
private static void checkCreateStatementSupported(
        int resultSetType, int resultSetConcurrency, int resultSetHoldability)
                throws SQLException
{
    if (   (   (resultSetType != ResultSet.TYPE_SCROLL_INSENSITIVE
            &&  resultSetType != ResultSet.TYPE_FORWARD_ONLY))
        || resultSetConcurrency != ResultSet.CONCUR_READ_ONLY
        || resultSetHoldability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
        throw SQLError.noSupport();
    }
}