Example usage for java.sql Clob getClass

List of usage examples for java.sql Clob getClass

Introduction

In this page you can find the example usage for java.sql Clob getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.etudes.jforum.dao.oracle.OracleUtils.java

/**
 * Writes clob to database //from   ww w . ja  v a 2  s . c  o  m
 * @param query
 * @param idForQuery
 * @param value
 * @throws IOException
 * @throws SQLException
 */
public static void writeClobUTF16BinaryStream(String query, int idForQuery, String value)
        throws IOException, SQLException {
    PreparedStatement p = JForum.getConnection().prepareStatement(query);
    p.setInt(1, idForQuery);

    ResultSet rs = p.executeQuery();
    rs.next();
    Clob clobval = rs.getClob(1);

    if (logger.isDebugEnabled())
        logger.debug("clobval is " + clobval.getClass().getName());

    Writer clobWriter = clobval.setCharacterStream(0L);

    char[] cbuffer = new char[value.length()];
    int srcBegin = 0, dstBegin = 0;
    value.getChars(srcBegin, value.length(), cbuffer, dstBegin);
    clobWriter.write(cbuffer);

    clobWriter.close();

    rs.close();
    p.close();
}