I’ve got an HSQL table with a CLOB column. I am using HSQL 2.2.8 as In-Memory database for test cases. I am trying to insert one entry of 41.169 bytes of data from a text file but I always get an exception telling me “string data, right truncation” from which I assume the entry was too large to be inserted and thus truncated. So I tried to insert smaller data entries which works perfectly fine, but in the end I really need to be capable to also insert the large entries.
The table is created using the following SQL command:
CREATE TABLE documents (
identifier VARCHAR(255) NOT NULL,
documentdata CLOB,
PRIMARY KEY(identifier)
);
I am trying to insert data using the following SQL command:
MERGE INTO documents
USING (VALUES(:identifier,:documentdata))
AS vals(identifier,documentdata)
ON documents.identifier=vals.identifier
WHEN NOT MATCHED THEN INSERT VALUES vals.identifier, vals.documentdata;
In this query :identifier and :documentdata are replaced by the corresponding values.
So my question is. Is there some limitation to the size of a CLOB entry in HSQL which I might configure somewhere. I am unable to understand the error, since I thought CLOB would allow me to save arbitrary sized data entries.
This is not the correct way to insert into a table with a large CLOB or BLOB column. Use the following statement with PreparedStatement, then set the CLOB as a character stream or String.