Take a look at the 8i App developer's guide for Large Objects & Java.  Something
like this might work  . . . (although you are using CLOB type, not BLOB).  It
also might be that you are using a LONG type, not a CLOB type (don't use LONG!).

-- Tim

// Create a Statement:
Statement stmt = conn.createStatement ();
try
{
ResultSet rset = stmt.executeQuery (
"SELECT sound FROM multimedia_tab WHERE clip_id = 1");
if (rset.next())
{
// retrieve the LOB locator from the ResultSet
BLOB sound_blob = ((OracleResultSet)rset).getBLOB (1);
OraclePreparedStatement ops =
(OraclePreparedStatement) conn.prepareStatement(
"INSERT INTO multimedia_tab (clip_id, sound) VALUES (2, ?)");
ops.setBlob(1, sound_blob);
ops.execute();
conn.commit();
conn.close();
}
}

Tim Yates wrote:

> Hiya!
>
> My Entity beans (BMP) have to write XML data into a CLOB field in an oracle
> database, but when I try to set it to a load of XML which is longer than
> 4000 characters, I get the following exception:
>
> javax.ejb.EJBException: Error executing SQL INSERT INTO CONTENT (DOCUMENTID,
> STARTDATE, ENDDATE, DEPARTMENT, TYPE, XML, SUBTYPE) VALUES ( ?, ?, ?, ?, ?,
> ?): java.sql.SQLException: ORA-01461: can bind a LONG value only for insert
> into a LONG column
>
> I am using classes12.zip for my drivers, and I am using the thin oracle
> driver...
>
> Pleeeeease has anyone else hit upon this, and can they help?  This is a
> complete showstopper!!  I cannot believe there is a 4000 char limit on CLOBS
> in Oracle 8i, else why use them?  I might as well use a varchar2...
>
> I think tonight is the night I painfully remove all my hair ;-)
>
> Tim...
>
> PS:  I write my clobs like this (in the BMP bit of the entity bean)
>
>       statement = connection.prepareStatement("INSERT INTO CONTENT
> (DOCUMENTID, STARTDATE, ENDDATE, DEPARTMENT, TYPE, XML, SUBTYPE) VALUES (?,
> ?, ?, ?, ?, ?, ?)");
>       statement.setString(1, documentid);
>       statement.setTimestamp(2, startdate);
>       statement.setTimestamp(3, enddate);
>       statement.setString(4, department);
>       statement.setString(5, type);
>       statement.setAsciiStream( 6, new ByteArrayInputStream(
> xml.getBytes() ), xml.length() ) ;
>       statement.setString(7, subtype);
>       if (statement.executeUpdate() != 1)
>       {
>         throw new CreateException("Error adding row");
>       }
>
> with xml being a java.lang.String...
>
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> List Help?:          [EMAIL PROTECTED]




--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to