Home » Developer & Programmer » JDeveloper, Java & XML » How to insert a new Clob with data great then 4000 bytes
How to insert a new Clob with data great then 4000 bytes [message #91068] Wed, 20 March 2002 22:14 Go to next message
Yoel Yaffe
Messages: 1
Registered: March 2002
Junior Member
Hi,
I'm working with the jdbc2.0,oracle driver: 8.1.7.0.0.
while I'm inserting a new Clob, that great then 4000 bytes, I'm getting an
error, one of:
1. "java.sql.SQLException: ORA-01461: can bind a LONG value only for insert
into a LONG column" - for the follow implementation:

String sqlString ="INSERT INTO BASIC_LOB_TABLE ( X, B, C ) VALUES (
?, '1010101', ?)";
PreparedStatement stmt = conn.prepareStatement(sqlString);
stmt.setString(1, "777");
Reader r = new InputStreamReader(new
StringBufferInputStream(prepareClobText(4005)));
stmt.setCharacterStream(2, r,4005);
stmt.executeQuery();

or

2. "java.sql.SQLException: ORA-01704: string literal too long" - for the follow implementation:

String sqlString ="INSERT INTO BASIC_LOB_TABLE ( X, B, C ) VALUES (
'222', '1010101', '"+prepareClobText(4005)+"')";
Statement st = conn.createStatement();
st.execute(sqlString);

is it a way to insert a new Clob that exceeded the 4000 bytes ?
thanks,
Re: How to insert a new Clob with data great then 4000 bytes [message #91176 is a reply to message #91068] Thu, 16 May 2002 22:28 Go to previous messageGo to next message
Boris
Messages: 5
Registered: February 2001
Junior Member
I have the same exact problem. Except I tried to use a StringReader for your first variant and didn't get any exceptions at all but instead an entry of size 0 in the table (Oracle 8.1)

After a bit of research, it appears JDBC 2.0 does not allow one to create new CLOB objects directly, and Oracle doesn't allow one to insert extra-long strings into CLOB columns without converting those strings to VARCHAR2 somewhere along the way. It seems JDBC 3.0 is going to allow at least editing, if not creation, of CLOBs, but until then we are all stuck. (?!?)
Re: How to insert a new Clob with data great then 4000 bytes [message #91300 is a reply to message #91068] Thu, 04 July 2002 03:26 Go to previous message
RameshJayaShankar.R
Messages: 1
Registered: July 2002
Junior Member
Use Long RAW instead of BLOB / CLOB, to accompany maximum datasize
Previous Topic: No more data to read from socket
Next Topic: Re: Sending file attachment using UTL_SMTP package
Goto Forum:
  


Current Time: Fri Mar 29 07:17:01 CDT 2024