User: mulder  
  Date: 00/11/06 09:00:52

  Modified:    src/main/org/jboss/ejb/plugins/jaws/jdbc JDBCCommand.java
  Log:
  Try to enable CLOB support.  This will decode it to a String while
  reading.  Writing is another matter...
  
  Revision  Changes    Path
  1.20      +18 -1     jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCCommand.java
  
  Index: JDBCCommand.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/ejb/plugins/jaws/jdbc/JDBCCommand.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- JDBCCommand.java  2000/10/21 02:28:02     1.19
  +++ JDBCCommand.java  2000/11/06 17:00:51     1.20
  @@ -22,8 +22,11 @@
   import java.io.ObjectOutputStream;
   import java.io.ObjectInputStream;
   import java.io.IOException;
  +import java.io.Reader;
  +import java.io.BufferedReader;
   
   import java.sql.Blob;
  +import java.sql.Clob;
   import java.sql.Connection;
   import java.sql.DriverManager;
   import java.sql.PreparedStatement;
  @@ -53,7 +56,7 @@
    * utility methods that database commands may need to call.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Justin Forder</a>
  - * @version $Revision: 1.19 $
  + * @version $Revision: 1.20 $
    */
   public abstract class JDBCCommand
   {
  @@ -397,6 +400,20 @@
           } else if(result instanceof Blob) {
               Blob blob = (Blob)result;
               bytes = blob.getBytes(1, (int)blob.length());
  +        } else if(result instanceof Clob && 
destination.getName().equals("java.lang.String")) {
  +            try {
  +                Reader in = new BufferedReader(((Clob)result).getCharacterStream());
  +                char[] buf = new char[512];
  +                StringBuffer string = new StringBuffer("");
  +                int count;
  +                while((count = in.read(buf)) > -1)
  +                    string.append(buf, 0, count);
  +                in.close();
  +                return string.toString();
  +            } catch(IOException e) {
  +                log.error("Unable to read a CLOB column: "+e);
  +                throw new SQLException("Unable to read a CLOB column: "+e);
  +            }
           } else {
               bytes = rs.getBytes(idx);
           }
  
  
  

Reply via email to