I went back to look at this, and immediately saw the silly mistake.

Here is the sanitized Clob implementation:

/**
  |  * <p>Title: StringClob</p>
  |  * <p>Description: A simple String buffer based implementation of a CLOB</p>
  |  * <p>Much code derived from mockrunner-0.2.7</p>
  |  * @author Whitehead
  |  * @version $Revision:   1.3  $
  |  */
  | 
  | public class StringClob
  |     implements Clob, Cloneable, Serializable, Externalizable {
  | 
  |   static final long serialVersionUID = 6518280165134659952L;
  |   private StringBuffer clobData;
  | 
  | public StringClob() {
  |   clobData = new StringBuffer();
  | }
  | 
  | public StringClob(String data)
  | {
  |   clobData = new StringBuffer(data);
  | }
  | 
  | public boolean setClobData(String s) {
  |   boolean changed = false;
  |   if(s!=null && clobData.toString().equalsIgnoreCase(s)) {
  |   } else {
  |     if(s==null) {
  |       if(clobData.length()!=0)  changed=true;
  |     } else {
  |       clobData.delete(0, clobData.length());
  |       clobData.append(s);
  |       changed=true;
  |     }
  |   }
  |   return changed;
  | }
  | 
  | public boolean appendClobData(String s) {
  |   boolean changed = false;
  |   if(s!=null) {
  |     clobData.append(s);
  |     changed=true;
  |   }
  |   return changed;
  | }
  | 
  | public long length() throws SQLException
  | {
  |     return clobData.length();
  | }
  | 
  | public void truncate(long len) throws SQLException
  | {
  |     clobData.setLength((int)len);
  | }
  | 
  | public InputStream getAsciiStream() throws SQLException
  | {
  |     return new ByteArrayInputStream(clobData.toString().getBytes());
  | }
  | 
  | public OutputStream setAsciiStream(long pos) throws SQLException
  | {
  |     throw new java.lang.UnsupportedOperationException("setAsciiStream");
  | }
  | 
  | public Reader getCharacterStream() throws SQLException
  | {
  |     return new StringReader(clobData.toString());
  | }
  | 
  | public Writer setCharacterStream(long pos) throws SQLException
  | {
  |    throw new java.lang.UnsupportedOperationException("setCharacterStream");
  | }
  | 
  | public String getSubString(long pos, int length) throws SQLException
  | {
  |     return clobData.substring((int)(pos - 1), (int)(pos - 1) + length);
  | }
  | 
  | public int setString(long pos, String str) throws SQLException
  | {
  |     return setString(pos, str, 0, str.length());
  | }
  | 
  | public int setString(long pos, String str, int offset, int len) throws SQLException
  | {
  |     str = str.substring(offset, offset + len);
  |     clobData.replace((int)(pos - 1), (int)(pos - 1)+ str.length(), str);
  |     return len;
  | }
  | 
  | public long position(String searchstr, long start) throws SQLException
  | {
  |     int index = clobData.toString().indexOf(searchstr, (int)(start - 1));
  |     if(-1 != index) index += 1;
  |     return index;
  | }
  | 
  | public long position(Clob searchClob, long start) throws SQLException
  | {
  |     return position(searchClob.getSubString(1, (int)searchClob.length()), start);
  | }
  | 
  | 
  | 
  | private class ClobOutputStream extends OutputStream
  | {
  |     private int index;
  | 
  |     public ClobOutputStream(int index)
  |     {
  |         this.index = index;
  |     }
  | 
  |     public void write(int byteValue) throws IOException
  |     {
  |         byte[] bytes = new byte[] {(byte)byteValue};
  |         try
  |         {
  |             setString(index + 1, new String(bytes));
  |         }
  |         catch(SQLException exc)
  |         {
  |             throw new IOException(exc.getMessage());
  |         }
  |         index++;
  |     }
  | }
  | 
  | public String toString()
  | {
  |     return clobData.toString();
  | }
  | 
  | public Object clone()
  | {
  |     try
  |     {
  |         StringClob clone = (StringClob)super.clone();
  |         clone.clobData = new StringBuffer(clobData.toString());
  |         return clone;
  |     }
  |     catch(CloneNotSupportedException exc)
  |     {
  |         exc.printStackTrace();
  |     }
  |     return null;
  | }
  | 
  | 
  |   public void writeExternal(ObjectOutput out) throws IOException {
  |     out.writeUTF(clobData.toString());    
  |   }
  | 
  |   public void readExternal(ObjectInput in) throws IOException,
  |       ClassNotFoundException {
  |     clobData = new StringBuffer(in.readUTF());
  |   }
  | 
  | }

So with the above code as the implementation, and the CMP code in the previous 
message, and the use of the OCI driver, I think you should be able to get it to work.

Let me know....

//Nicholas

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3832184#3832184

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3832184


-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to