Manage memory for large objects

Whenever a large object (a BYTE, TEXT, BLOB, or CLOB data type) is fetched from the database server, the data is either cached into memory or stored in a temporary file (if it exceeds the memory buffer).

You can specify how large object data is stored by using an environment variable, LOBCACHE, that you include in the connection property list, as follows:
  • To set the maximum number of bytes allocated in memory to hold the data, set the LOBCACHE value to that number of bytes.

    If the data size exceeds the LOBCACHE value, the data is stored in a temporary file. If a security violation occurs during creation of this file, the data is stored in memory.

  • To always store the data in a file, set the LOBCACHE value to 0.

    In this case, if a security violation occurs, HCL OneDB™ JDBC Driver makes no attempt to store the data in memory.

  • To always store the data in memory, set the LOBCACHE value to a negative number.

    If the required amount of memory is not available, HCL OneDB JDBC Driver throws the SQLException message Out of Memory.

If the LOBCACHE size is invalid or not defined, the default size is 4096.

You can set the LOBCACHE value through the database URL, as follows:
URL = jdbc:onedb://158.58.9.37:9088/test;user=guest;password=iamaguest;lobcache=4096";

The preceding example stores the large object in memory if the size is 4096 bytes or fewer. If the large object exceeds 4096 bytes, HCL OneDB JDBC Driver tries to create a temporary file. If a security violation occurs, memory is allocated for the entire large object. If that fails, the driver throws an SQLException message.

Here is another example:
URL = "jdbc:onedb://hostname:9088/testdb;user=guest;passwd=whoknows;lobcache=0";

The preceding example uses a temporary file for storing the fetched large object.

Here is a third example:
URL = "jdbc:onedb://icarus:7110/testdb;user=guest;passwd=whoknows;lobcache=-1";

The preceding example always uses memory to store the fetched large object.

For programming information about how to use the TEXT and BYTE data types in a Java™ program, see BYTE and TEXT data types. For programming information about how to use the BLOB and CLOB data types in a Java program, see Smart large object data types.