Java Code Examples for java.sql.ResultSet.CONCUR_UPDATABLE

The following are Jave code examples for showing how to use CONCUR_UPDATABLE 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: OpenVertretung   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: lams   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 4
Project: ProyectoPacientes   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 5
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 6
Project: sstore-soft   File: JDBCResultSet.java   View Source Code Vote up 5 votes
/**
 * 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);
    }
}
 
Example 7
Project: the-vigilantes   File: MysqlIO.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 8
Project: s-store   File: JDBCResultSet.java   View Source Code Vote up 5 votes
/**
 * 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);
    }
}
 
Example 9
Project: OpenVertretung   File: MysqlIO.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 10
Project: lams   File: MysqlIO.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 11
Project: ProyectoPacientes   File: MysqlIO.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 12
Project: BibliotecaPS   File: MysqlIO.java   View Source Code Vote up 5 votes
/**
 * 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());
}
 
Example 13
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 14
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 15
Project: sstore-soft   File: JDBCPreparedStatement.java   View Source Code Vote up 3 votes
/**
 * <!-- 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;
}
 
Example 16
Project: sstore-soft   File: JDBCResultSet.java   View Source Code Vote up 3 votes
/**
 * <!-- 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;
}
 
Example 17
Project: s-store   File: JDBCPreparedStatement.java   View Source Code Vote up 3 votes
/**
 * <!-- 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;
}
 
Example 18
Project: s-store   File: JDBCResultSet.java   View Source Code Vote up 3 votes
/**
 * <!-- 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;
}