NClob (Java SE 26 & JDK 26)
Description: declaration: module: java.sql, package: java.sql, interface: NClob
Keywords: java.sql.NClob interface

# Interface NClob

All Superinterfaces:
  `AutoCloseable, Clob`

public interface NClob extends Clob
The mapping in the Java programming language for the SQL `NCLOB` type. An SQL `NCLOB` is a built-in type that stores a Character Large Object using the National Character Set as a column value in a row of a database table.

The `NClob` interface extends the `Clob` interface which provides methods for getting the length of an SQL `NCLOB` value, for materializing a `NCLOB` value on the client, and for searching for a substring or `NCLOB` object within a `NCLOB` value. A `NClob` object, just like a `Clob` object, is valid for the duration of the transaction in which it was created. Methods in the interfaces `ResultSet`, `CallableStatement`, and `PreparedStatement`, such as `getNClob` and `setNClob` allow a programmer to access an SQL `NCLOB` value. In addition, this interface has methods for updating a `NCLOB` value.

To release resources used by the `NClob` object, applications must call either the `Clob.free()` or the `Clob.close()` method. Any attempt to invoke a method other than `Clob.free()` or `Clob.close()` after the `NClob` object has been closed, will result in a `SQLException` being thrown.

All methods on the `NClob` interface must be fully implemented if the JDBC driver supports the data type.

Since:
  1.6

- ## Method Summary

  ### Methods declared in interface Clob

  `close, free, getAsciiStream, getCharacterStream, getCharacterStream, getSubString, length, position, position, setAsciiStream, setCharacterStream, setString, setString, truncate`
  Modifier and Type
  Method
  Description
  `default void`
  `close()`
  Closes and releases the resources held by this `Clob` object.
  `void`
  `free()`
  Closes and releases the resources held by this `Clob` object.
  `InputStream`
  `getAsciiStream()`
  Retrieves the `CLOB` value designated by this `Clob` object as an ascii stream.
  `Reader`
  `getCharacterStream()`
  Retrieves the `CLOB` value designated by this `Clob` object as a `java.io.Reader` object (or as a stream of characters).
  `Reader`
  `getCharacterStream(long pos, long length)`
  Returns a `Reader` object that contains a partial `Clob` value, starting with the character specified by pos, which is length characters in length.
  `String`
  `getSubString(long pos, int length)`
  Retrieves a copy of the specified substring in the `CLOB` value designated by this `Clob` object.
  `long`
  `length()`
  Retrieves the number of characters in the `CLOB` value designated by this `Clob` object.
  `long`
  `position(String searchstr, long start)`
  Retrieves the character position at which the specified substring `searchstr` appears in the SQL `CLOB` value represented by this `Clob` object.
  `long`
  `position(Clob searchstr, long start)`
  Retrieves the character position at which the specified `Clob` object `searchstr` appears in this `Clob` object.
  `OutputStream`
  `setAsciiStream(long pos)`
  Retrieves a stream to be used to write Ascii characters to the `CLOB` value that this `Clob` object represents, starting at position `pos`.
  `Writer`
  `setCharacterStream(long pos)`
  Retrieves a stream to be used to write a stream of Unicode characters to the `CLOB` value that this `Clob` object represents, at position `pos`.
  `int`
  `setString(long pos, String str)`
  Writes the given Java `String` to the `CLOB` value that this `Clob` object designates at the position `pos`.
  `int`
  `setString(long pos, String str, int offset, int len)`
  Writes `len` characters of `str`, starting at character `offset`, to the `CLOB` value that this `Clob` represents.
  `void`
  `truncate(long len)`
  Truncates the `CLOB` value that this `Clob` designates to have a length of `len` characters.