Search in sources :

Example 1 with JdbcClob

use of org.h2.jdbc.JdbcClob in project h2database by h2database.

the class JdbcResultSet method getNClob.

/**
 * Returns the value of the specified column as a Clob.
 *
 * @param columnIndex (1,2,...)
 * @return the value
 * @throws SQLException if the column is not found or if the result set is
 *             closed
 */
@Override
public NClob getNClob(int columnIndex) throws SQLException {
    try {
        int id = getNextId(TraceObject.CLOB);
        if (isDebugEnabled()) {
            debugCodeAssign("NClob", TraceObject.CLOB, id, "getNClob(" + columnIndex + ")");
        }
        Value v = get(columnIndex);
        return v == ValueNull.INSTANCE ? null : new JdbcClob(conn, v, id);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : Value(org.h2.value.Value) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Example 2 with JdbcClob

use of org.h2.jdbc.JdbcClob in project h2database by h2database.

the class JdbcConnection method createClob.

/**
 * Create a new empty Clob object.
 *
 * @return the object
 */
@Override
public Clob createClob() throws SQLException {
    try {
        int id = getNextId(TraceObject.CLOB);
        debugCodeAssign("Clob", TraceObject.CLOB, id, "createClob()");
        checkClosedForWrite();
        try {
            Value v = session.getDataHandler().getLobStorage().createClob(new InputStreamReader(new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0);
            session.addTemporaryLob(v);
            return new JdbcClob(this, v, id);
        } finally {
            afterWriting();
        }
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) Value(org.h2.value.Value) Savepoint(java.sql.Savepoint) DbException(org.h2.message.DbException) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException)

Example 3 with JdbcClob

use of org.h2.jdbc.JdbcClob in project h2database by h2database.

the class JdbcConnection method createNClob.

/**
 * Create a new empty NClob object.
 *
 * @return the object
 */
@Override
public NClob createNClob() throws SQLException {
    try {
        int id = getNextId(TraceObject.CLOB);
        debugCodeAssign("NClob", TraceObject.CLOB, id, "createNClob()");
        checkClosedForWrite();
        try {
            Value v = session.getDataHandler().getLobStorage().createClob(new InputStreamReader(new ByteArrayInputStream(Utils.EMPTY_BYTES)), 0);
            session.addTemporaryLob(v);
            return new JdbcClob(this, v, id);
        } finally {
            afterWriting();
        }
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) Value(org.h2.value.Value) Savepoint(java.sql.Savepoint) DbException(org.h2.message.DbException) SQLClientInfoException(java.sql.SQLClientInfoException) SQLException(java.sql.SQLException)

Example 4 with JdbcClob

use of org.h2.jdbc.JdbcClob in project h2database by h2database.

the class JdbcResultSet method getNClob.

/**
 * Returns the value of the specified column as a Clob.
 *
 * @param columnLabel the column label
 * @return the value
 * @throws SQLException if the column is not found or if the result set is
 *             closed
 */
@Override
public NClob getNClob(String columnLabel) throws SQLException {
    try {
        int id = getNextId(TraceObject.CLOB);
        if (isDebugEnabled()) {
            debugCodeAssign("NClob", TraceObject.CLOB, id, "getNClob(" + columnLabel + ")");
        }
        Value v = get(columnLabel);
        return v == ValueNull.INSTANCE ? null : new JdbcClob(conn, v, id);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : Value(org.h2.value.Value) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Example 5 with JdbcClob

use of org.h2.jdbc.JdbcClob in project h2database by h2database.

the class JdbcResultSet method getClob.

/**
 * Returns the value of the specified column as a Clob.
 *
 * @param columnIndex (1,2,...)
 * @return the value
 * @throws SQLException if the column is not found or if the result set is
 *             closed
 */
@Override
public Clob getClob(int columnIndex) throws SQLException {
    try {
        int id = getNextId(TraceObject.CLOB);
        if (isDebugEnabled()) {
            debugCodeAssign("Clob", TraceObject.CLOB, id, "getClob(" + columnIndex + ")");
        }
        Value v = get(columnIndex);
        return v == ValueNull.INSTANCE ? null : new JdbcClob(conn, v, id);
    } catch (Exception e) {
        throw logAndConvert(e);
    }
}
Also used : Value(org.h2.value.Value) DbException(org.h2.message.DbException) SQLException(java.sql.SQLException)

Aggregations

SQLException (java.sql.SQLException)6 DbException (org.h2.message.DbException)6 Value (org.h2.value.Value)6 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStreamReader (java.io.InputStreamReader)2 SQLClientInfoException (java.sql.SQLClientInfoException)2 Savepoint (java.sql.Savepoint)2 BigInteger (java.math.BigInteger)1 Array (java.sql.Array)1 Clob (java.sql.Clob)1 Date (java.sql.Date)1 NClob (java.sql.NClob)1 Time (java.sql.Time)1 Calendar (java.util.Calendar)1 UUID (java.util.UUID)1 ValueBoolean (org.h2.value.ValueBoolean)1 ValueDate (org.h2.value.ValueDate)1 ValueDouble (org.h2.value.ValueDouble)1 ValueLong (org.h2.value.ValueLong)1 ValueShort (org.h2.value.ValueShort)1