user215005
user215005

Reputation: 175

ORA-01704: string literal too long in oracle 10g

I am getting ORA-01704: string literal too long error when there is more than 4000 chars for the field RAWDATA. The data type is CLOB. I am using java 1.4 and oracle 10g.

stmt = conn.prepareStatement("INSERT INTO RAWDATA_EQUIFAX (REQ_ID, BUREAU_CODE, RAWDATA, RESP_TIME) VALUES (?, ?, ?, ?)");

stmt.setInt(1, RequestID);
stmt.setString(2, bureau_code);
stmt.setString(3, rawData);
stmt.setTimestamp(4, new Timestamp(date.getTime()));
stmt.executeUpdate();
conn.commit();

Upvotes: 1

Views: 3426

Answers (2)

horec
horec

Reputation: 404

I think you should use this to set Clob parameter to the PreparedStatement:

Clob clob = conn.createClob();
clob.setString(1, rawData);
stmt.setClob(3, clob);
clob.free();

Upvotes: 0

Keppil
Keppil

Reputation: 46239

Don't use PreparedStatement#setString() to set a Clob.
There is a PreparedStatement#setClob() method that you can use instead.

Upvotes: 3

Related Questions