Question
· 21 hr ago

Expose %Stream property in JDBC as CLOB

I need to reproduce a table (in fact a view, but let's start with a simple table 😊) in IRIS as the currently used in Oracle.

I need to expose/project one column to JDBC as CLOB, in my class I have the corresponding property defined as:

Property GlobStream As %Stream.GlobalCharacter;

In JDBC this column is projected as LONGVARCHAR, this is compliant with the documentation but I need to project it as CLOB.

In addition, I'm no expert in JDBC but wit seems that LONGVARCHAR has a Maximum Length 32,700 characters in JDBC, not quite enough for an arbitrary stream.

Is it possible to project a %Stream to JDBC as a CLOB?
If so, how?
If not, why? How can I give access to IRIS stream properties via JDBC?

Product version: IRIS 2024.1
Discussion (3)2
Log in or sign up to continue

%Stream.GlobalCharacter properties in InterSystems IRIS are projected as LONGVARCHAR (-1) for JDBC. This complies with the default mapping, and the JDBC specification applies the maximum length limit for LONGVARCHAR, which may not suit arbitrary stream data requirements.

To utilize CLOBs adequately, the JDBC standard interfaces provide BLOB and CLOB handling. For instance, you can retrieve and set CLOB data within a Java program utilizing the java.sql.Clob interface:

Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT MyCLOBColumn FROM MyTable");
rs.next(); // Access the Clob data
java.sql.Clob clob = rs.getClob(1);
// Example to print length
System.out.println("Clob length = " + clob.length());
// Perform further operations
clob.free(); // Close explicitly

This demonstrates the correct interaction between Java and CLOB stream data types in IRIS. Ensure that your implementation explicitly opens and manages stream field attributes to prevent constraints like JDBC defaults on LONGVARCHAR types from becoming limiting. [1]

Sources:

See

If you run the following code, then the type of variables a and b in the generated class will be %Stream.GlobalCharacter

create table dc.test
(
LONGVARCHAR,
b CLOB
)
In addition, I'm no expert in JDBC but wit seems that LONGVARCHAR has a Maximum Length 32,700 characters in JDBC, not quite enough for an arbitrary stream.

Max Size for LONGVAR(BINARY/CHAR) = 2147483647, for VAR(BINARY/CHAR) = 4096

PS: By the way, in DbVisualizer you can view all types supported by the JDBC driver, their numeric codes, maximum sizes, and much more.