Example usage for java.sql Types BLOB

List of usage examples for java.sql Types BLOB

Introduction

In this page you can find the example usage for java.sql Types BLOB.

Prototype

int BLOB

To view the source code for java.sql Types BLOB.

Click Source Link

Document

The constant in the Java programming language, sometimes referred to as a type code, that identifies the generic SQL type BLOB.

Usage

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Retrieves the value of the designated column in this
 * <code>CachedRowSetImpl</code> object as a <code>Blob</code> object
 * in the Java programming language./*from   www.  ja v  a2 s  .c om*/
 *
 * @param columnIndex the first column is <code>1</code>, the second
 *        is <code>2</code>, and so on; must be <code>1</code> or larger
 *        and equal to or less than the number of columns in this rowset
 * @return a <code>Blob</code> object representing an SQL <code>BLOB</code> value
 * @throws SQLException if (1) the given column index is out of bounds,
 *            (2) the cursor is not on one of this rowset's rows or its
 *            insert row, or (3) the designated column does not store an
 *            SQL <code>BLOB</code> value
 * @see #getBlob(String)
 */
public Blob getBlob(int columnIndex) throws SQLException {
    Blob value;

    // sanity check.
    checkIndex(columnIndex);
    // make sure the cursor is on a valid row
    checkCursor();

    if (RowSetMD.getColumnType(columnIndex) != java.sql.Types.BLOB) {
        System.out.println(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.type").toString(),
                RowSetMD.getColumnType(columnIndex)));
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
    }

    setLastValueNull(false);
    value = (Blob) (getCurrentRow().getColumnObject(columnIndex));

    // check for SQL NULL
    if (value == null) {
        setLastValueNull(true);
        return null;
    }

    return value;
}